| Welcome to Webforumz.com. |
|
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.
|
|
|
Apr 15th, 2008, 10:19
|
#2 (permalink)
|
|
Lead Administrator
Join Date: Nov 2005
Location: Always About
Age: 27
Posts: 1,061
|
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 )
Last edited by saltedm8; Apr 15th, 2008 at 10:22.
|
|
|
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.
|
|
|
Apr 15th, 2008, 13:03
|
#4 (permalink)
|
|
Nerdy Moderator
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 517
|
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
|
|
|
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 
|
|
|
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
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 ))
|
|
|
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
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.
|
|
|
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 
__________________
|
|
|
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 
|
|
|
| Thread Tools |
|
|
| 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
HTML code is Off
|
|
|
|
|
|