Hi all, I’m trying to create a form that has 2 upload fields that emails the attachments. I’m not sure how to send 2 attachments via a mail form, but I have built them with one before.
If you look at my code, you’ll notice that I’ve tried to concatenate $_FILES variables. This clearly isn’t working. If anyone has any suggestions, I’d appreciate it.
My code is below.
<?php
$submit = $_POST['submit'];
if($submit){
$to = "[EMAIL="jpearson@ts24.com"]jpearson@ts24.com[/EMAIL]";
$subject = "Application from your LCC Site";
$from = stripslashes($_POST['fName']).' '.stripslashes($_POST['lName'])"<".stripslashes($_POST['email']).">";
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$cv = $_POST['cv'];
$resume = $_POST['resume'];
$comments = $_POST['comments'];
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$tmp_name = $_FILES['cv']['tmp_name'] . $_FILES['resume']['tmp_name'];
$type = $_FILES['cv']['type'] . $_FILES['resume']['type'];
$name = $_FILES['cv']['name'] . $_FILES['resume']['name'];
$size = $_FILES['cv']['size'] . $_FILES['resume']['size'];
$message = "$phone
$address
$city, $state $zip
$comments";
if (file_exists($tmp_name)){
if(is_uploaded_file($tmp_name)){
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
}
$headers = "From: $from
" . "MIME-Version: 1.0
" . "Content-Type: multipart/mixed;
" . " boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.
" . "--{$mime_boundary}
" . "Content-Type: text/plain; charset=\"iso-8859-1\"
" . "Content-Transfer-Encoding: 7bit
" . $message . "
";
$message .= "--{$mime_boundary}
" . "Content-Type: {$type};
" . " name=\"{$name}\"
" . "Content-Transfer-Encoding: base64
" . $data . "
" . "--{$mime_boundary}--
";
mail($to, $subject, $message, $headers)
}
?>
<table width="600" cellSpacing="0" cellPadding="0" border="0" id="FrameSMGlobal">
<tr>
<td colspan="2">
<br /><p>Make a difference in a job you enjoy! Travel Solutions continuously seeks talented, proactive, service-oriented professionals. We hire our employees from a range of industries and disciplines to build a strong and diverse team at the forefront of the travel industry.</p><br /><p>In our work environment, we strive to recognize the value of each employee. We empower each person to be a leader, encouraging everyone's individual skills and talents in a collaborative, fun and motivating atmosphere.</p><br /><p>To become a member of our dynamic team, complete the online form and "submit" it for review.</p><br /><p>*Required Fields</p><br /><?php echo $result; ?>
</td>
</tr>
<tr>
<td valign="top" align="left" width="300">
<form name="form" method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data" onsubmit="javascript:return validateApply()">
<p>*FIRST NAME:</p>
<input name="fName" type="text" /><br />
<p>*LAST NAME:</p>
<input name="lName" type="text" /><br />
<p>PHONE NUMBER:</p>
<input name="phone" type="text" /><br />
<p>*EMAIL:</p>
<input name="email" type="text" />
</td>
<td align="left" valign="top" width="300">
<p>ADDRESS:</p>
<input name="address" type="text" /><br />
<p>CITY:</p>
<input name="city" type="text" /><br />
<p>STATE:</p>
<input name="state" type="text" /><br />
<p>ZIP:</p>
<input name="zip" type="text" />
</td>
</tr>
<tr>
<td align="center" valign="middle" colspan="2">
<div class="SepLine5OrangH"></div>
</td>
</tr>
<tr>
<td valign="top" align="left" width="300">
<p>COVER LETTER:</p>
<input name="cv" type="file" /><br />
<p>*RESUME:</p>
<input name="resume" type="file" />
</td>
<td valign="top" align="left" width="300">
<p>COMMENTS:</p>
<textarea name="comments"></textarea>
<input type="submit" value="SEND" class="sendbutton" />
</form>
</td>
</tr>
</table>