View Single Post
  #1 (permalink)  
Old Apr 15th, 2008, 09:53
westy westy is offline
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Won't send jpeg format? Please check my php.

Hello, please can you help me make my form work. I have tested it and it allows me to upload a gif file and send no problem, however when I try to send with a jpeg file it comes up wrong file format?

PHP: Select all

<?php 
 
 
       $strname
=ucfirst($_REQUEST["strname"]);           
    
$stremail=$_REQUEST["stremail"]; 
  
$strweb=$_REQUEST["strweb"];
   
$strad=$_REQUEST["strad"];   
    
$strcat=$_REQUEST["strcat"];      
    
$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=="image/jpeg" or $filetype=="image/jpg" or $filetype=="image/gifor $filetype=="image/bmp"
    { 
 
        
$message"$strname just filled in your Buy Ad form.\n 
     Their web address to link to is: $strweb
     Their adsquare window request is: $strad
     Their category is: $strcat
     Their alt text is: $strcomments
              Their e-mail address was: $stremail"
;
    
// MAIL SUBJECT 
    
$subject "Buy Advert Form"
 
    
// TO MAIL ADDRESS 
 
 
    
$to="sales@adsquare.tv"
/* 
    // 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: $stremail\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 
'<font style="font-family:Verdana, Arial; font-size:11px; color:#ffffff; font-weight:bold">Thank you. Your details have been sent Successfully. You will receive a e-mail from AdSquare shortly<br /></font>'

else 
    { 
        echo 
'<font style="font-family:Verdana, Arial; font-size:11px; color:#ffffff; font-weight:bold">Wrong file format. Mail was not sent.</font>'
        
//echo "<script>window.location.href='buy.htm';</script>"; 
    

?>
I have got the filetype image/jpeg in the code but am not sure if that is right? Thanks for your time

Last edited by Jack Franklin; Apr 15th, 2008 at 16:47.
Reply With Quote