Mail script not reading file attachment.

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed Apr 04, 2012 5:19 am

Mail script not reading file attachment.

Postby catnold » Wed Apr 04, 2012 5:26 am

Hi All,

I appreciate any assistance that any may offer. I have a php webmailer that sends email without issue, but when I try to send an attachment, it fails at "if (is_uploaded_file($fileatt))" like the file is not there. I have confirmed that the files are in the correct file location and the file path has been verified with our web host(GoDaddy). This is the section that is failing:

echo " before if satament ";
$fileatt = $_FILES['file']['tmp_name'];
$fileatt_type = $_FILES['file']['type'];
$fileatt_name = $_FILES['file']['name'];
echo $fileatt = "D:\Hosting\\"."2664876\html\uploads\\".$fileatt_name;
echo " Filename: ".$fileatt_name." ";
if (is_uploaded_file($fileatt))
echo "Start of the if statement.";
$file = fopen($fileatt, 'rb');
$data = fread($file,filesize($fileatt));
echo "in if satament";

$data = chunk_split(base64_encode($data));
$notice_text = "This is a multi-part message in MIME format.";

My echo statements are returning the proper information as far as I can tell:

display_errors = on error_reporting = E_ALL & E_NOTICE uploads/compSidebar.htmlThe file compSidebar.html has been uploaded to uploads/compSidebar.html before if satament D:\Hosting\2664876\html\uploads\compSidebar.html Filename: compSidebar.html FAILED TO OPEN THE FILE! This is a multi-part message in MIME format. --==MULTIPART_BOUNDARY_73ba9dd1468fde11a8403328a6c9a556 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --==MULTIPART_BOUNDARY_73ba9dd1468fde11a8403328a6c9a556 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit


nd, from echoing the message itself, I get the final message boundary for the attachment:

--==MULTIPART_BOUNDARY_73ba9dd1468fde11a8403328a6c9a556 Content-Type: multipart/mixed Content-Type: text/html; name=compSidebar.html Content-Disposition: attachment; filename=compSidebar.html Content-Transfer-Encoding: base64 --==MULTIPART_BOUNDARY_73ba9dd1468fde11a8403328a6c9a556--

Any assistance would be greatly appreciated. I can provide the full code if needed, but it is too big to post here.

Thank you,


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: Google [Bot] and 2 guests