Web Design and Development Forums

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 > Program Your Website > PHP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Apr 15th, 2008, 09:53   #1 (permalink)
New Member
 
Join Date: Feb 2008
Location: UK
Posts: 9
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/gif" or $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.
westy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 10:19   #2 (permalink)
Lead Administrator
 
saltedm8's Avatar
 
Join Date: Nov 2005
Location: Always About
Age: 27
Posts: 1,061
Blog Entries: 1
Send a message via MSN to saltedm8
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 )
__________________
recipebite.co.uk - its a working progress...

Last edited by saltedm8; Apr 15th, 2008 at 10:22.
saltedm8 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 12:50   #3 (permalink)
Up'n'Coming Member
 
Join Date: Feb 2006
Location: London
Age: 25
Posts: 99
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.
jimz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 13:03   #4 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 517
Blog Entries: 4
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
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 16:31   #5 (permalink)
New Member
 
Join Date: Feb 2008
Location: UK
Posts: 9
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
westy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 18:56   #6 (permalink)
New Member
 
Join Date: Feb 2008
Location: UK
Posts: 9
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 ))
westy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 18:58   #7 (permalink)
New Member
 
Join Date: Feb 2008
Location: UK
Posts: 9
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.
westy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 19:11   #8 (permalink)
Up'n'Coming Member
 
Join Date: Feb 2006
Location: London
Age: 25
Posts: 99
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/gif" or $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
__________________

jimz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 15th, 2008, 19:47   #9 (permalink)
New Member
 
Join Date: Feb 2008
Location: UK
Posts: 9
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
westy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 HTML Forum 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 Forum 1 Feb 12th, 2007 22:38
print file (pdf, jpeg or word doc) ecat JavaScript Forum 0 Sep 15th, 2006 18:28



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 10:57.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59