I wrote a small program in php for a website this code allows a user to upload a file and it emails it to whomever we declare as the recipient. This code works great on my windows server but when I put it on the Linux based server in fails to read the Mime types. Please help with ideas. Victor J. Bozzelle
This is the windows code that works.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Upload Results</title>
</head>

<body>
    <?php
        // if there is an attachment
        if(!empty($_FILES['attachment']['name']))
        {
        //store some variables
        $file_name = $_FILES['attachment']['name'];
        $temp_name = $_FILES['attachment']['tmp_name'];
        $file_type = $_FILES['attachment']['type'];

        // get the extension of the file
        $base = basename($file_name);
        $extension = substr($base, strlen($base)-4, strlen($base));

        //only these files will be allowed
        $allowed_extensions = array(".doc","docx",".pdf",".zip");
        // check for the correct file type
            if(in_array($extension,$allowed_extensions))
            {
                //mail essentials
                $from = $_POST['email'];
                $to = "vicsportbikecustomz@gmail.com";
                $subject = "Part Time Electronics Instructor";
                $message = "A new resume has been sent.";

                //things yopu need
                $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 .= "Reply-To: ".$replyto."\r\n";
                $header .= "MIME-Version: 1.0\r\n";

                //declare multipart email
                $header .="Content-Type: multipart/mixed; boundary=\"" .$uid."\"\r\n\r\n";
                $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 attachmnet
                $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\r\n";
                $header .= $content."\r\n\r\n";

                //send the mail dont need message because in text part of header
                if (mail($to, $subject, "", $header))
                {
                echo "Your RESUME has been sent! Thank You.";
                } else{
                echo "There was an ERROR sending your RESUME please try again later.";
                }
                exit();
            } else {    
            echo "That file type is not allowed!";
            }
        } else {
        echo "No file was selected! Please try again!";
        }
    ?>  
</body>
</html>
Here is a modified linux version where i removed the \r commands due to errors.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>File Upload Results</title>
</head>

<body>
    <?php
        // if there is an attachment
        if(!empty($_FILES['attachment']['name']))
        {
        //store some variables
        $file_name = $_FILES['attachment']['name'];
        $temp_name = $_FILES['attachment']['tmp_name'];
        $file_type = $_FILES['attachment']['type'];

        // get the extension of the file
        $base = basename($file_name);
        $extension = substr($base, strlen($base)-4, strlen($base));

        //only these files will be allowed
        $allowed_extensions = array(".doc","docx",".pdf",".zip");
        // check for the correct file type
            if(in_array($extension,$allowed_extensions))
            {
                //mail essentials
                $from = $_POST['email'];
                $to = "vicsportbikecustomz@gmail.com";
                $subject = "Part Time Electronics Instructor";
                $message = "A new resume has been sent.";

                //things yopu need
                $file = $temp_name;
                $content = chunk_split(base64_encode(file_get_contents($file)));
                $uid = md5(uniqid(time()));

                //standard mail headers
                $header = "From: ".$from."\n";
                $header .= "Reply-To: ".$replyto."\n";
                $header .= "MIME-Version: 1.0\n";

                //declare multipart email
                $header .="Content-Type: multipart/mixed; boundary=\"" .$uid."\"\n\n";
                $header .="This is a multi-part message in MIME format.\n";

                //plain text part
                $header .= "--".$uid."\n";
                $header .= "Content-type:text/plain; charset=iso-8859-1\n";
                $header .= "Content-Transfer-Encoding: 7bit\n\n";
                $header .= $message."\n\n";

                //file attachmnet
                $header .= "--".$uid."\n";
                $header .= "Content-Type: ".$file_type."; name=\"".$file_name."\"\n";
                $header .= "Content-Transfer-Encoding: base64\n";
                $header .= "Content-Disposition: attachment; filename=\"".$file_name."\"\n\n";
                $header .= $content."\n\n";

                //send the mail dont need message because in text part of header
                if (mail($to, $subject, "", $header))
                {
                echo "Your RESUME has been sent! Thank You.";
                } else{
                echo "There was an ERROR sending your RESUME please try again later.";
                }
                exit();
            } else {    
            echo "That file type is not allowed!";
            }
        } else {
        echo "No file was selected! Please try again!";
        }
    ?>  
</body>
</html>

Hi and welcome to daniweb. Let me be the first to say please use code tags. Also as for your scripts problem, I am guessing the exif module or mime type module is not installed on your Linux server. So check that required modules are installed by using <?php phpinfo(); ?> and see if your required modules are in that list. Also please post any errors that appear.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.