//Gather file data
$filename = $_FILES['filename1']['name'];
$tmp = $_FILES['filename1']['tmp_name'];
$sep = md5(time());
//Get file contents
$fdata = chunk_split(base64_encode(file_get_contents($tmp))); //Encode data into text form
//Email To address
$to = "ramkrism@gmail.com";
//Determine mime type
$ext = explode('.', $filename);
$ext = $ext[1];
if($ext == "JPG" || $ext == "jpg" || $ext == "JPEG" || $ext == "jpeg") {
$mime_type = "image/jpeg";
}
elseif($ext == "gif" || $ext == "GIF") {
$mime_type = "image/gif";
}
else {
exit("Error: Wrong file type!");
}
//message
$message = "Email content";
// headers
$headers = "From: \"From Name\"
MIME-Version: 1.0
Content-Type: Multipart/Mixed; boundary=\"$sep\"
charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
--$sep
Content-Type: $mime_type; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$filename\"
$fdata --$sep";
$subject = "Email Subject Here";
if(mail($to, $subject, $message, $headers)){
echo 'Sent';
}
else {
echo 'Not Sent';
}
?>