PHP ATTACHMENT FORM - IE PROBLEM!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dev01
Forum Newbie
Posts: 2
Joined: Tue Jun 17, 2008 10:09 am

PHP ATTACHMENT FORM - IE PROBLEM!!!

Post by Dev01 »

Hey all

I have a form in PHP that does attachments with submit button etc etc. This is form images, however, my BIG issue is, it works brilliantly in Firefox, not in IE.

Please can someone have a look and see if they can tell me where I am going wrong?

Code: Select all

<?php
     
                     
       $strname=ucfirst($_REQUEST["strname"]);
    $straddress=ucfirst($_REQUEST["straddress"]);
    $strcity=ucfirst($_REQUEST["strcity"]);
    $strstate=ucfirst($_REQUEST["strstate"]);       
       
       $phone=$_REQUEST["strno"];
       if($phone != ""){ $strno=$phone; } else { $strno="-"; }   
       
    $stremail=$_REQUEST["stremail"];   
    $strcomments=ucfirst($_REQUEST["strcomments"]);
 
   
    $filename=$_FILES["strresume"]["name"];
    $filetype=$_FILES["strresume"]["type"];
    $filesize=$_FILES["strresume"]["size"];
    $filetemp=$_FILES["strresume"]["tmp_name"];
 
 
       
    if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword" or $filetype=="image/jpg" or $filetype=="image/jpeg" or $filetype=="image/bmp" or $filetype=="image/JPG" or $filetype=="images/jpe" or $filetype=="image/gif" or $filetype=="images/eps" or $filetype=="images/tiff" or $filetype=="images/psd" or $filetype=="application/pdf" or $filetype=="application/cdr")
    {
   
        $message= '
   
   
            <table cellspacing="0" cellpadding="8" border="0" width="400">
            <tr>
                <td colspan="2"></td>
            </tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Name</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strname.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Address</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$straddress.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>County</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcity.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Postcode</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strstate.'</td>
              </tr>
              <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Telephone</strong></td>
              <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strno.'</td>
              </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
            <tr bgcolor="#eeeeee">
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Email</strong></td>
                <td style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$stremail.'</td>
            </tr>
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
           
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;"><strong>Sending by post?</strong></td>
            </tr>               
            <tr bgcolor="#eeeeee">
                <td colspan="2" style="font-family:Verdana, Arial; font-size:11px; color:#333333;">'.$strcomments.'</td>
            </tr>               
                                   
            <tr><td colspan="2" style="padding:0px;"><img src="images/whitespace.gif" alt="" width="100%" height="1" /></td></tr>
         </table>
 
 
           
 
';
 
    // MAIL SUBJECT
 
    $subject = "Customer Image Attachment";
   
    // TO MAIL ADDRESS
   
   
    $to="info@somewhere.co.uk";
 
/*
    // MAIL HEADERS
                       
    $headers  = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "From: Name <name@name.com>\n";
 
*/
 
 
 
    // MAIL HEADERS with attachment
 
    $fp = fopen($strresume, "rb");
    $file = fread($fp, $strresume_size);
 
    $file = chunk_split(base64_encode($file));
    $num = md5(time());
   
        //Normal headers
 
    $headers  = "From: My website\r\n";
       $headers  .= "MIME-Version: 1.0\r\n";
       $headers  .= "Content-Type: multipart/mixed; ";
       $headers  .= "boundary=".$num."\r\n";
       $headers  .= "--$num\r\n";
 
        // This two steps to help avoid spam   
 
    $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";         
 
        // With message
       
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
       $headers .= "Content-Transfer-Encoding: 8bit\r\n";
       $headers .= "".$message."\n";
       $headers .= "--".$num."\n"; 
 
        // Attachment headers
 
    $headers  .= "Content-Type:".$strresume_type." ";
       $headers  .= "name=\"".$strresume_name."\"r\n";
       $headers  .= "Content-Transfer-Encoding: base64\r\n";
       $headers  .= "Content-Disposition: attachment; ";
       $headers  .= "filename=\"".$strresume_name."\"\r\n\n";
       $headers  .= "".$file."\r\n";
       $headers  .= "--".$num."--";
 
   
   
    // SEND MAIL
       
       @mail($to, $subject, $message, $headers);
   
 
     fclose($fp);
 
    echo "<script>window.location.href='order.html';</script>";
}
else
    {
        echo '<font style="font-family:Verdana, Arial; font-size:11px; color:#F3363F; font-weight:bold">Incorrect file format, please ensure your image is one of the following: PDF, JPG/JPEG, TIFF, EPS, PSD, CDR, BMP, thank you, please go back and try again.</font>';
        //echo "<script>window.location.href='careers.html';</script>";
    }
 
?>
And here is the HTML:

Code: Select all

<div class="content2">
    <form class="attach_upload" method="post" action="upload.php" enctype="multipart/form-data">
<label class="label1_upload">Name:</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="strname"  /><br>
<label class="label1_upload">Address:</label>
<input class="attachaddy_upload" type="text" size="10" maxlength="40" name="straddress" /><br>
<label class="label1_upload">County:</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="strcity" /><br>
<label class="label1_upload">Postcode:</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="strstate" /><br>
<label class="label1_upload">Phone Number:</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="strno" /><br>
<label class="label1_upload">E-mail address:</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="stremail" /><br>
<label class="label1_upload">Sending your images by post? (Yes/No)</label>
<input class="attach1_upload" type="text" size="10" maxlength="40" name="strcomments" /><br>
<br><br>
<label class="label1_upload">Attach your picture</label>
<input class="attach1_upload" type="file" size="30" maxlength="50" name="strresume" accept="text/*" />
<br><br>
<input class="submit1_upload" type="submit" value="Send" name="submit" onClick="return validate();" />
</form>
</div>
Was wondering if it has something to do with the size of the attachment, even though when used in Firefox, nothing like that matters as it just works. Internet Explorer ... :banghead:

Thanks very much everyone, very, very much

Dev01
Dev01
Forum Newbie
Posts: 2
Joined: Tue Jun 17, 2008 10:09 am

Re: PHP ATTACHMENT FORM - IE PROBLEM!!!

Post by Dev01 »

Hey all

I have come to conclusion that this problem is to do with file sizes. If I try attaching a jpg that is large and small, the larger one will not go through, but the smaller one will.

Does this help anyone?

Thanks very much

Dev01
Post Reply