brandon215 Posted May 24, 2013 Share Posted May 24, 2013 Hi! I'm hoping someone can help me out with a HTML form using PHP. The form allows users to upload a file (and that part works) but it's supposed to attach that file in the email it sends with the form info. I've looked and looked and looked but I haven't been able to find a resolution. HELP!!! <?php $fileName = $_FILES["fileatt"]["name"]; // The file name $fileTmpLoc = $_FILES["fileatt"]["tmp_name"]; // File in the PHP tmp folder $fileType = $_FILES["fileatt"]["type"]; // The type of file it is $fileSize = $_FILES["fileatt"]["size"]; // File size in bytes $fileErrorMsg = $_FILES["fileatt"]["error"]; // 0 for false... and 1 for true move_uploaded_file($fileTmpLoc, "uploads/$fileName"); if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); } $data = chunk_split(base64_encode($data)); $From = $_POST['From']; $Email = $_POST['Email']; $Campaign = $_POST['Campaign']; $Subject = $_POST['Subject']; $email_sub = "Email request confirmation"; $datepicker = $_POST['datepicker']; $Specialty = implode(', ', empty($_POST['Specialty']) ? array() : $_POST['Specialty'] ); $Template = $_POST['Template']; $url = 'http://lwwjournals.com/#calendar'; $Notes = $_POST['Notes']; $formcontent=" New Email Request from $Name \n \n --------------------------------------- \n \n From: $From \n Email: $Email \n Campaign: $Campaign \n Subject: $Subject \n Date: $datepicker \n Specialty: $Specialty \n Template: $Template \n Uploaded File: $fileName \n Notes: $Notes $data"; $formcontent2=" Hey there! Thanks for submitting your request, here's a copy of the information you submitted. \n \n --------------------------------------- \n \n From: $From \n Email: $Email \n Campaign: $Campaign \n Subject: $Subject \n Date: $datepicker \n Specialty: $Specialty \n Uploaded File: $fileName \n Template: $Template \n Notes: $Notes"; $recipient = "email@dummyemail.com"; $subject = "2013 Email Request"; mail($recipient, $subject, $formcontent,'From: emails@lwwjournals.com','-f emails@lwwjournals.com' ) or die("Error!"); mail($Email, $email_sub, $formcontent2,'From: emails@lwwjournals.com','-f emails@lwwjournals.com' ) or die("Error!"); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?> index.html mail.php Quote Link to comment https://forums.phpfreaks.com/topic/278359-file-uploads-but-doesnt-attach-to-the-sent-email/ Share on other sites More sharing options...
Muddy_Funster Posted May 27, 2013 Share Posted May 27, 2013 I don't see where you are attaching the $data variable to the email, or where you define it as a multipart MIME Quote Link to comment https://forums.phpfreaks.com/topic/278359-file-uploads-but-doesnt-attach-to-the-sent-email/#findComment-1432479 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.