i have a form that you can add an attachment to to email. the email is getting sent and received, but it contains no attachment.
here's the form code that has the attach button:
<tr>
<td colspan="3"><input type="hidden" name="MAX_FILE_SIZE" value="2097152">
<span class="burgundybold">Submit your resume (optional)</span><br><br>
<input name="upload" type="file" size="30" class="text">
</td></tr>
here's the attachment part:
if(!empty($POST['upload'])){
$file = $POST['upload'];
} else {
$file = NULL;
$read = NULL;
}
$mailto = "myemail@here.com";
//$locations;
$subject = "Application submittal";
$mime_boundary = md5(uniqid(time()));
if(!empty($_POST['upload'])){
$mimeType = mime_content_type($file);
$fp=fopen($file, "r");
$read=fread($fp, filesize($file));
$read=base64_encode($read);
$read=chunk_split($read);
}
$headers_ = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $mime_boundary . "\"\r\n";
$headers .= "From: [email]info@site.com[/email] \r\n";
$body = "--".$mime_boundary."\r\n";
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$body .= "Content-Transfer-Encoding: binary\r\n";
$body .= "\r\n";
$body .= "<b><font size =\"5\">Application from web site.</font></b>" .
"<br><br>" . "<b>Career interests: </b>" . rtrim($careers) .
...
$body .= "--".$mime_boundary."\r\n";
$body .= "Content-Transfer-Encoding: base64";
$body .= "Content-disposition:attachment;filename=". $file;
$body .= "Content-Type: " . $mimeType . "; name=" . $file;
$body .= "\r\n";
$body .= $read;
$body .= "\r\n";
$body .= "--".$mime_boundary."--\r\n";