I have this code which works great for gif's...but it crashes on the jpeg image upload...Please Help!
<?php
// Check to see if the form has been posted
if (isset($POST['SendFile']))
{
// Set the Array of acceptable FileTypes
$FileTypes=array("image/jpeg", "image/gif");
// Check to ensure the uploaded file is of correct type
if (in_array($FILES['UPLDoc']['type'],$FileTypes))
{
// Set the upload directory
$UploadDir = 'upload/';
// Move the file
move_uploaded_file($FILES['UPLDoc']['tmp_name'], $UploadDir . $FILES['UPLDoc']['name']);
// Open the file and read the contents into a string
$FileName=$UploadDir.$FILES['UPLDoc']['name'];
$FilePointer=fopen($FileName, "r");
$File=fread($FilePointer, filesize ($FileName));
fclose($FilePointer);
// Encode and chunk split the data for the e-mail
$File=chunk_split(base64_encode($File));
// Set the receiving e-mail address
$EMail="email@email.com";
// Set the headers of the e-mail
$Headers="From: someone@domain.com\n";
$Headers.="Reply-To: someone@domain.com\n";
$Headers.="MIME-Version: 1.0\n";
$Headers.="Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n";
$Headers.="X-Sender: someone@domain.com\n";
$Headers.="X-Mailer: PHP4\n";
$Headers.="X-Priority: 3\n";
$Headers.="Return-Path: someone@domain.com\n";
$Headers.="This is a multi-part Contentin MIME format.\n";
// Set the Content of the e-mail
$Content="--MIME_BOUNDRY\n";
$Content.="Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$Content.="Content-Transfer-Encoding: quoted-printable\n";
$Content.="\n";
$Content.="".$POST['Name']." just sent you the attached file for review.\n";
$Content.="\n";
$Content.="--MIME_BOUNDRY\n";
$Content.="Content-Type: ".$FILES['UPLDoc']['type']."; name=\"".$FILES['UPLDoc']['name']."\"\n";
$Content.="Content-disposition: attachment\n";
$Content.="Content-Transfer-Encoding: base64\n";
$Content.="\n";
$Content.="$File\n";
$Content.="\n";
$Content.="--MIME_BOUNDRY--\n";
// Set the Subject of the e-mail
$Subject="New file to review";
// Send the e-mail
mail($EMail,$Subject,$Content,$Headers);
}else
{
echo "You cannot upload this type of file";
}
}
?>
<FORM ENCTYPE="multipart/form-data" METHOD="POST" ACTION="<?=$_SERVER['PHP_SELF'];?>">
<INPUT TYPE="HIDDEN" NAME="SendFile" VALUE="Send File">
<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="100000">
Your Name: <INPUT TYPE="TEXT" NAME="Name"><BR>
Select Document: <INPUT TYPE="FILE" NAME="UPLDoc"><BR>
<INPUT TYPE="SUBMIT" NAME="SendFile" VALUE="Send File">
</FORM>