Won't send jpeg format? Please check my php.

This is a discussion on "Won't send jpeg format? Please check my php." within the PHP Forum section. This forum, and the thread "Won't send jpeg format? Please check my php. are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 15th, 2008, 09:53
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

  #2 (permalink)  
Old Apr 15th, 2008, 10:19
saltedm8's Avatar
Lead Administrator

SuperMember
Join Date: Nov 2005
Location: Always About
Age: 27
Posts: 1,298
Blog Entries: 1
Thanks: 1
Thanked 6 Times in 6 Posts
Re: Won't send jpeg format? Please check my php.

add a JPG in CAPTIALS, see if that works

( i dont know much about php, but i do know that can make a difference sometimes )
__________________
My Recipe forum...don't click here
Last Blog Entry: Basic Advice for newbies (Feb 1st, 2008)

Last edited by saltedm8; Apr 15th, 2008 at 10:22.
Reply With Quote
  #3 (permalink)  
Old Apr 15th, 2008, 12:50
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Can you make a post with the output of this when you try to upload the jpg:
Code: Select all
echo'<pre>'; print_r($_FILES); exit;
Place it right after your opening <?php tag.

that would help to find the problem.

Last edited by jimz; Apr 15th, 2008 at 12:53.
Reply With Quote
  #4 (permalink)  
Old Apr 15th, 2008, 13:03
CloudedVision's Avatar
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 942
Blog Entries: 8
Thanks: 2
Thanked 22 Times in 22 Posts
Send a message via AIM to CloudedVision Send a message via MSN to CloudedVision Send a message via Skype™ to CloudedVision
Re: Won't send jpeg format? Please check my php.

PHP: Select all

var_dump($filetype); 

Add that right after you declare $filetype, then upload a JPEG and tell us what it outputs
__________________
echo "Take it easy, ".$CloudedVision;
.links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; }
<quote>&quot;I think it's wrong that only one company makes the game Monopoly&quot; - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
Reply With Quote
  #5 (permalink)  
Old Apr 15th, 2008, 16:31
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Thank you for all your replys, will try them out and let you know the outcome. Thanks again
Reply With Quote
  #6 (permalink)  
Old Apr 15th, 2008, 18:56
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Quote:
Originally Posted by jimz View Post
Can you make a post with the output of this when you try to upload the jpg:
Code: Select all
echo'<pre>'; print_r($_FILES); exit;
Place it right after your opening <?php tag.

that would help to find the problem.
This is what was displayed when i put that code in and tried uploading a jpeg.

Array( [strresume] => Array ( [name] => bannerhorizontal.jpg [type] => image/pjpeg [tmp_name] => /tmp/php4CPWf1 [error] => 0 [size] => 34414 ))
Reply With Quote
  #7 (permalink)  
Old Apr 15th, 2008, 18:58
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Quote:
Originally Posted by saltedm8 View Post
add a JPG in CAPTIALS, see if that works

( i dont know much about php, but i do know that can make a difference sometimes )
I tried changing to capitals but no luck thank you for trying.
Reply With Quote
  #8 (permalink)  
Old Apr 15th, 2008, 19:11
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Ok, I think I've spotted your problem. Did you notice when you did "print_r($_FILES)" the type was "image/pjpeg"?

So, you just need to add that to the end of your if statement like so:

PHP: Select all

if($filetype=="application/octet-stream" or $filetype=="image/jpeg" or $filetype=="image/jpg" or $filetype=="image/gifor $filetype=="image/bmp" or $filetype=="image/pjpeg"
...by the way, pjpeg stands for progressive jpeg

Give that if statement a go, and see if that works
Reply With Quote
  #9 (permalink)  
Old Apr 15th, 2008, 19:47
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Won't send jpeg format? Please check my php.

Thank you so much jimz I hadn't even noticed the p in front of jpeg!!!
Works fine now, I really appreciate all your help
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] jpeg quality in flash movies danny322 Flash & Multimedia Forum 3 Dec 6th, 2007 12:54
Problem with PNG transparency on JPEG background Rob Riot UK Web Page Design 4 May 11th, 2007 12:10
Converting JPEG to gif/bmp lalmm PHP Forum 2 May 7th, 2007 17:45
whats the difference between jpeg, gif, png etc SJMAC Graphics and 3D 1 Feb 12th, 2007 22:38
print file (pdf, jpeg or word doc) ecat JavaScript Forum 0 Sep 15th, 2006 18:28


All times are GMT. The time now is 20:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43