Hello,

I have a script that gets information and has you upload a photo via a form and sends the information to a specified email address. For some reason everything is formatted correctly but when you click to view the attachment in the email it says that the file is empty. Here is my code if anyone can help me figure this issue out that would be great.

PHP Code:
// If there is an attachment
       
if (!empty($_FILES['upload']['name'])) {
       
            
// Store attachment details in variables
            
$file_name $_FILES['upload']['name'];
            
$temp_name $_FILES['upload']['tmp_name'];
            
$file_type $_FILES['upload']['type'];
            
            
// define allowed file types
            
$allowed = array('image/bmp''image/pjpeg''image/jpeg''image/JPG''image/X-PNG''image/PNG''image/png''image/x-png''image/gif''image/jp2''image/x-macpaint''image/x-portable-bitmap''image/x-portable-pixmap');
            
            
// Check that this file type is allowed
            
if(in_array($file_type$allowed)) {
            
                
// Mail Essenstials
                
$from "webmaster@pinit.com"// Insert the email address that is sending the form.
                
$to "mp-mccoy@hotmail.com"// Insert your email address here
                
$subject "New Pin Submission";
                
$message "Category:     " .$category"\r\n";
                
$message .= "Organization:     " .$organziation"\r\n\r\n";
                
$message .= "Address:     " .$pin_address"\r\n";
                
$message .= "                   " .$city_and_state"," .$zip"\r\n";
                
$message .= "Phone:     " .$phone"\r\n\r\n";
                
$message .= "Description:     " .$text_area1"\r\n\r\n";
                
$message .= "Website:     " .$website1"\r\n";
                
$message .= "Social Media URL:     " .$website2"\r\n\r\n";
                
$message .= "About:     " .$text_area2"\r\n";
          
                
// Items to create attachment in email
                
$file $temp_name;
                
$content chunk_split(base64_encode(file_get_contents($file)));
                
$uid md5(uniqid(time()));
                
                
// Standard Mail Headers
                
$header "From: ".$from"\r\n";
                
$header .= "MIME-Version: 1.0\r\n";
                
                
// Declaring we have multiple kinds of email (plain text and attachment)
                
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid"\"\r\n\r";
                
$header .= "This is a multi-part message in MIME format. \r\n";
                
                
// Plain Text Part
                
$header .= "--" .$uid"\r\n";
                
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
                
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                
$header .= $message"\r\n\r\n";
                
                
// File Attachment
                
$header .= "--" .$uid"\r\n";
                
$header .= "Content-Type: " .$file_type"; name=\"" .$file_name"\"\r\n";
                
$header .= "Content-Transfer-Encoding: base64\r\n";
                
$header .= "Content-Disposition: attachment; filename=\"" .$file_name"\"\r\n";
                
$header .= $content"\r\n\r\n";
       
            }else{
                
$errors['upload'] = 'File Type Not Accepted';
            }
        }else{
            
$errors['upload'] = 'No Files was Uploaded';
        }
            
        if (empty(
$errors)) {
            
// send the email
            
$ok mail($to$subject""$header); 
            if (
$ok) { 
                echo 
"<p>mail sent to $to!</p>"
            }else { 
                echo 
"<p>mail could not be sent!</p>"
            }
            exit();