scrubbicus Posted July 11, 2009 Share Posted July 11, 2009 I'm trying to make an upload form for only image files and internet explorer isn't deteching the extension correctly. Does IE have different extension names? My code is like this $ext = 'jpg png bmp jpeg gif'; foreach($_FILES['pic']['tmp_name'] as $k=>$tmpfile) { $type = $_FILES['pic']['type'][$k]; if(!strstr($type,$ext)) $err++; } The upload works fine on FireFox, OPera, and Safari but Internet Explorer is giving by an error. Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/ Share on other sites More sharing options...
trq Posted July 11, 2009 Share Posted July 11, 2009 And what exactly is the error? PHP runs on the server, so is unelected by what browser your using. Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/#findComment-873323 Share on other sites More sharing options...
trq Posted July 11, 2009 Share Posted July 11, 2009 ps: That code won't stop anyone uploading whatever file type they want to. Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/#findComment-873324 Share on other sites More sharing options...
scrubbicus Posted July 11, 2009 Author Share Posted July 11, 2009 Why not? cause then if they upload an exe it will search that string for exe and it won't find it so it'll give the the $err and later down the road the upload won't happen. Well the error was created by me. It says the Your uploaded images are the wrong type of file which was generated when a loop scanned through each file, grabbed the extension looked for the extension in my string of valid ones and couldn't find it. So I'm thinking a .JPEG is something else on IE? Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/#findComment-873333 Share on other sites More sharing options...
trq Posted July 11, 2009 Share Posted July 11, 2009 Why not? cause then if they upload an exe it will search that string for exe and it won't find it so it'll give the the $err and later down the road the upload won't happen. I could easily upload jpg.exe and it will get through. The best way to check to see if a file is an image is to use get_image_size, this will return false if the file isn't an image, regardless of what file extension your using. Remember, file extensions mean nothing on Linux. Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/#findComment-873344 Share on other sites More sharing options...
scrubbicus Posted July 12, 2009 Author Share Posted July 12, 2009 oh ya your right. well what if i just exploded the filename and used the second element? $element = jpg.exe explode it so i got array(2) { [0] => 'jpg' [1] => 'exe' } then i just check out $element[1]; I look up that function though thanks Link to comment https://forums.phpfreaks.com/topic/165570-ie-have-different-upload-image-types/#findComment-873807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.