iPixel Posted October 24, 2007 Share Posted October 24, 2007 Ok so i got this upload script and everything works 100% fine in IE. At one point in the script i check for file type, i only want jpg files.(code below) The problem is firefox... whenever i use FF to upload a picture, that code snipped craps out and gives me the error msg. $userfile_name = $_FILES['image']['name']; $userfile_tmp = $_FILES['image']['tmp_name']; $userfile_size = $_FILES['image']['size']; $userfile_type = $_FILES['image']['type']; if($userfile_type == "image/pjpeg") { echo ""; } else { ?> <center><br /><br /><br /> <font color="#FF0000">The picture file you are trying to upload is not in jpg format. Please resave the image with the jpg format and try again. Thank You!.</font><BR /> </center> <meta http-equiv=refresh content='5;url=javascript:history.go(-1)'> <? exit; } Any and all ideas suggestions are more then welcome and appreciated ! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/ Share on other sites More sharing options...
Wuhtzu Posted October 24, 2007 Share Posted October 24, 2007 Can we have the error message? Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-376979 Share on other sites More sharing options...
iPixel Posted October 24, 2007 Author Share Posted October 24, 2007 the else statement is the error msg ... I suppose another way to do this would be to check the remaining characters after the ( . ) and check if they are jpg, jpeg, JPG, JPEG, right ? but how would i avoid from mis-reading files named fun.stuff.jpg ? Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-376982 Share on other sites More sharing options...
Wuhtzu Posted October 24, 2007 Share Posted October 24, 2007 Try using this instead: <?php if(($userfile_type == "image/jpeg") || ($userfile_type == "image/jpeg")) { } ?> I'm sure it's the mime type which causes the problems... Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-377000 Share on other sites More sharing options...
iPixel Posted October 24, 2007 Author Share Posted October 24, 2007 image/jpeg || image/jpeg or do you mean image/jpeg || image/jpg ? ill give this a shot .. for now my temporary fix is $file_ext = substr($userfile_name, -4); if(($file_ext == ".jpg") || ($file_ext == ".JPG") || ($file_ext == "jpeg") || ($file_ext == "JPEG")) { echo ""; } else { ?> <center><br /><br /><br /> <font color="#FF0000">-- The picture file you are trying to upload is not in jpg format. Please resave the image with the jpg format and try again. Thank You!. --</font><BR /> </center> <meta http-equiv=refresh content='5;url=javascript:history.go(-1)'> <? exit; } But i still want to figure out why that other snippet wont work .. Thanks Wuhtzu Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-377001 Share on other sites More sharing options...
Wuhtzu Posted October 24, 2007 Share Posted October 24, 2007 Sorry my mistake, I meant this: <?php if(($userfile_type == "image/pjpeg") || ($userfile_type == "image/jpeg")) { } ?> You are using "image/pjpeg" in the code you originally posted. Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-377003 Share on other sites More sharing options...
iPixel Posted October 24, 2007 Author Share Posted October 24, 2007 Hahahah KUDOS to you my friend ! You were right ! that worked just fine... Thanks a bunch ! ~iPixel Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-377009 Share on other sites More sharing options...
Wuhtzu Posted October 24, 2007 Share Posted October 24, 2007 No problem. So your problem was that IE and FF determined your pictures to be of different mime type... IE: "image/pjpeg" (weird ?) FF: "image/jpeg" Quote Link to comment https://forums.phpfreaks.com/topic/74595-solved-heres-a-weird-one-why-does-this-happen/#findComment-377013 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.