Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

php attachment mailen met variabele naam

Pagina: 1
Acties:

  • Paultje3181
  • Registratie: November 2002
  • Laatst online: 22-11 18:34
Ik probeer een mail te sturen vanuit een form waarbij de bestandnaam variabel is. Nu lukt het mailen prima, alleen heet het bestand $_POST[Factuurnummer].pdf. Ook als ik bij name=$_POST[Factuurnummer].'.pdf' invul werkt het niet en $_POST[Factuurnummer].pdf werkt ook niet. Ik zie even echt niet waarom dit niet werkt. Hopelijk dat iemand mij de gouden hint kan geven?
PHP:
1
2
3
4
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/pdf; name="$_POST[Factuurnummer].'.pdf'"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment 

  • Thorchy
  • Registratie: Januari 2009
  • Laatst online: 20-11 11:57
En wat als je het volgende doet?
PHP:
1
Content-Type: application/pdf; name="<?php echo $_POST[Factuurnummer]; ?>'.pdf'"

Want wat je nu doet is gewoon letterlijk de "$_POST[Factuurnummer]" als tekst tonen in plaats van te echo'en in PHP.

[ Voor 30% gewijzigd door Thorchy op 15-04-2013 17:36 ]

Why do we tell you to turn it off and on again? Because we don't have the slightest clue what's wrong with it, and it's really easy to induce coma in computers and have their built-in team of automatic doctors try to figure it out for us.


  • Lucacker
  • Registratie: Augustus 2011
  • Laatst online: 23-04-2019
Je variabele staat buiten de <?php en ?>, daardoor wordt hij niet uitgevoerd.
Ook is het handig om dingen die je uit een array ophaalt tussen ' ' te zetten $string['arraynummer'];

PHP:
1
2
3
4
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/pdf; name="<?php echo $_POST['Factuurnummer']; ?>.pdf'"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment 


Ik denk dat dit wel zou moeten werken

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 20-11 11:59

NMe

Quia Ego Sic Dico.

Sorry, maar als je dit soort dingen zelf niet ziet, dan kun je je hier beter niet mee bezighouden. Niet in de laatste plaats omdat je nu wagenwijd open staat voor header-injectie. ;)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Verwijderd

Gebruik alsjeblieft een goede standaard mailer class of framework.

  • TheDevilOnLine
  • Registratie: December 2012
  • Laatst online: 18-11 16:17
Lucacker schreef op maandag 15 april 2013 @ 19:14:
Je variabele staat buiten de <?php en ?>, daardoor wordt hij niet uitgevoerd.
Ook is het handig om dingen die je uit een array ophaalt tussen ' ' te zetten $string['arraynummer'];

PHP:
1
2
3
4
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/pdf; name="<?php echo $_POST['Factuurnummer']; ?>.pdf'"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment 


Ik denk dat dit wel zou moeten werken
Je vergeet nog een single quote (') na het .pdf weg te halen
PHP:
1
2
3
4
--PHP-mixed-<?php echo $random_hash; ?>  
Content-Type: application/pdf; name="<?php echo $_POST['Factuurnummer']; ?>.pdf"  
Content-Transfer-Encoding: base64  
Content-Disposition: attachment 


En zoals NMe ook al zegt... Niet echt de meest veilige code
Pagina: 1