Ell20 Posted February 26, 2008 Share Posted February 26, 2008 Hi, I have a fully working image upload script, in Mozilla Firefox, however if I attempt to upload images in Internet Explorer it dosent like it and says Picture not uploaded, wrong file type. It only seems to occur with JPG, JPEGS. if($_POST['changeimage']){ $tab1=0; $tab3=1; $tab2=0; $tab4=0; $tab5=0; list($width, $height) = getimagesize($_FILES['imagefile']['tmp_name']); if ($width <= 350 && $height <= 300) { if (($_FILES['imagefile']['type'] == "image/jpeg") || ($_FILES["imagefile"]["type"] == "image/gif") || ($_FILES["imagefile"]["type"] == "image/png")) { copy ($_FILES['imagefile']['tmp_name'], "/home/scrpgco/public_html/images/profiles/".$_FILES['imagefile']['name'] = md5($_FILES['imagefile']['name'] . rand()) . $_FILES['imagefile']['name']) or die ("Could not copy"); $message = "Picture Uploaded!"; if($userinfo['profimage']!=""){ $location = $userinfo['profimage']; $file_delete = "/home/scrpgco/public_html/images/profiles/$location"; unlink($file_delete); updatedata($id,"profimage=''"); } updatedata($id,"profimage='{$_FILES['imagefile']['name']}'"); } else { $message = "Picture not uploaded, wrong filetype (".$_FILES['imagefile']['name'].")"; } } else { $message= "Picture not uploaded, picture dimensions are too big (".$_FILES['imagefile']['name'].")"; } } Can anyone shed any light as to why this might work in Mozilla but not IE? Thanks for any help Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/ Share on other sites More sharing options...
Ell20 Posted February 27, 2008 Author Share Posted February 27, 2008 Anyone any idea on this? Cheers Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477934 Share on other sites More sharing options...
DarkerAngel Posted February 27, 2008 Share Posted February 27, 2008 Your scrpit seems dependent on file header information, try a print_r($_FILES); on a fail and see what is returned. Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477939 Share on other sites More sharing options...
Ell20 Posted February 27, 2008 Author Share Posted February 27, 2008 This is what got returned when it fails: Array ( [imagefile] => Array ( [name] => new.jpeg [type] => image/pjpeg [tmp_name] => /tmp/php2lvzG1 [error] => 0 => 3003 ) ) Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477945 Share on other sites More sharing options...
DarkerAngel Posted February 27, 2008 Share Posted February 27, 2008 This is what got returned when it fails: Array ( [imagefile] => Array ( [name] => new.jpeg [type] => image/pjpeg [tmp_name] => /tmp/php2lvzG1 [error] => 0 => 3003 ) ) Well since it returned [type] => image/pjpeg, Which is something that is not on your approved file header list, you have to add it. if (($_FILES['imagefile']['type'] == "image/jpeg") || ($_FILES["imagefile"]["type"] == "image/gif") || ($_FILES["imagefile"]["type"] == "image/png") || ($_FILES["imagefile"]["type"] == "image/pjpeg")) New Code: <?php if($_POST['changeimage']){ $tab1=0; $tab3=1; $tab2=0; $tab4=0; $tab5=0; list($width, $height) = getimagesize($_FILES['imagefile']['tmp_name']); if ($width <= 350 && $height <= 300) { if (($_FILES['imagefile']['type'] == "image/jpeg") || ($_FILES["imagefile"]["type"] == "image/gif") || ($_FILES["imagefile"]["type"] == "image/png") || ($_FILES["imagefile"]["type"] == "image/pjpeg")) { copy ($_FILES['imagefile']['tmp_name'], "/home/scrpgco/public_html/images/profiles/".$_FILES['imagefile']['name'] = md5($_FILES['imagefile']['name'] . rand()) . $_FILES['imagefile']['name']) or die ("Could not copy"); $message = "Picture Uploaded!"; if($userinfo['profimage']!=""){ $location = $userinfo['profimage']; $file_delete = "/home/scrpgco/public_html/images/profiles/$location"; unlink($file_delete); updatedata($id,"profimage=''"); } updatedata($id,"profimage='{$_FILES['imagefile']['name']}'"); } else { $message = "Picture not uploaded, wrong filetype (".$_FILES['imagefile']['name'].")"; } } else { $message= "Picture not uploaded, picture dimensions are too big (".$_FILES['imagefile']['name'].")"; } } ?> Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477952 Share on other sites More sharing options...
Ell20 Posted February 27, 2008 Author Share Posted February 27, 2008 Excellent, seems to have solved the problem. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477960 Share on other sites More sharing options...
Ell20 Posted February 27, 2008 Author Share Posted February 27, 2008 Is there not a topic solved button anymore?! Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477963 Share on other sites More sharing options...
DarkerAngel Posted February 27, 2008 Share Posted February 27, 2008 Is there not a topic solved button anymore?! It's Currently MIA Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477969 Share on other sites More sharing options...
aschk Posted February 27, 2008 Share Posted February 27, 2008 Just a quick simplifying option for you. Instead of if(something = blah blah OR something = blah blah OR something = blah blah) try $arr = array("blah blah", "blah blah", "blah blah"); if(in_array("something", $arr); It then means if you start doing the lookups for accepted types from a database, then all you need to do is build the array ($arr) and viola it works. Link to comment https://forums.phpfreaks.com/topic/93216-image-upload-quick-question/#findComment-477992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.