sblake161189 Posted September 20, 2011 Share Posted September 20, 2011 Hi All, I have a form which POSTs data through to PHP, it then places this on a HTML mail and then emails the company. I then have two attachment fields on the form, one for their CV and the other for some sort of ID. The attachments appear on the HTML email but when you try and open them or download and open them they come up with an error as though they are corrupt. However the odd thing is if I open it on my iPhone the attachments work perfect. Its not just my PC at fault as it doesnt work on many computers/OS's. The actual PHP attachment code is below: <?php $unid = md5(time()); for($i=0;$i<count($_FILES["fileAttach"]["name"]); $i++) { if($_FILES["fileAttach"]["name"][$i] != "") { $filename = $_FILES["fileAttach"]["name"][$i]; $attachment = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i]))); $mailheader .= "--" . $unid . "\n"; $mailheader .= "Content-Type: multipart/mixed; name=" . $filename . "\n"; $mailheader .= "Content-Transfer-Encoding: base64"."\n"; $mailheader .= "Content-Disposition: attachment; filename=" . $filename . "\n"; $mailheader .= $attachment; } } ?> What am I doing wrong. More code can be provided if needed. Cheers in advance! Quote Link to comment https://forums.phpfreaks.com/topic/247505-php-mail-attachments-wont-load/ Share on other sites More sharing options...
sblake161189 Posted September 20, 2011 Author Share Posted September 20, 2011 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/247505-php-mail-attachments-wont-load/#findComment-1271042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.