Jump to content

PHP Mail Attachments wont load


sblake161189

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.