Jump to content

Recommended Posts

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'];
$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

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.