jonstu Posted March 6, 2007 Share Posted March 6, 2007 hey people, I am running a image uploading script on my domain. It seems to do the job fine in firefox and opera browsers BUT in the internet explorer, it gives me this error. imagecopyresampled(): the given argument is not a valid image resource. My question why MS IE is not letting my script run successfully while other browsers seem to let it work fine. I have been looking for help all around and it seems this forum might rescue me. please help. why is it not working in IE only? Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/ Share on other sites More sharing options...
Barand Posted March 6, 2007 Share Posted March 6, 2007 Simple answer - haven't a clue! I might be able to help more if I had some code to look at and test Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201142 Share on other sites More sharing options...
jonstu Posted March 6, 2007 Author Share Posted March 6, 2007 here is the simple code: $resized = imagecreatetruecolor(450, 450); if($HTTP_POST_FILES['userfile']['type'] == 'image/png') $original = imagecreatefrompng($HTTP_POST_FILES['userfile']['tmp_name']); if($HTTP_POST_FILES['userfile']['type'] == 'image/jpg' || $HTTP_POST_FILES['userfile']['type'] == 'image/jpeg') $original = imagecreatefromjpeg($HTTP_POST_FILES['userfile']['tmp_name']); if($HTTP_POST_FILES['userfile']['type'] == 'image/gif') $original = imagecreatefromgif($HTTP_POST_FILES['userfile']['tmp_name']); if($HTTP_POST_FILES['userfile']['type'] == 'image/bmp') $original = imagecreatefromwbmp($HTTP_POST_FILES['userfile']['tmp_name']); imagecopyresampled($resized, $original, 0, 0, 0, 0, $nwidth, $nheight, $owidth, $oheight); thanks for your reply. Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201199 Share on other sites More sharing options...
Barand Posted March 6, 2007 Share Posted March 6, 2007 I think it should be "image/pjpeg" instead of "image/jpeg" (M$ weird mime type) Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201217 Share on other sites More sharing options...
willpower Posted March 6, 2007 Share Posted March 6, 2007 dont you just love the " Barand" Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201219 Share on other sites More sharing options...
jonstu Posted March 6, 2007 Author Share Posted March 6, 2007 okay, I made the change as suggested but now it is showing me the error in mozilla firefox and opera (which were working fine before change). IE seems to do the resizing but makes the image quality a junk. The error is still the same but this time its other browsers and not IE. please help. error: imagecopyresampled(): supplied argument is not a valid Image resource on line 134 Warm Regards. you guys are a life saver! Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201260 Share on other sites More sharing options...
Barand Posted March 6, 2007 Share Posted March 6, 2007 dont you just love the " Barand" I don't think Jonstu does right now Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201263 Share on other sites More sharing options...
jonstu Posted March 6, 2007 Author Share Posted March 6, 2007 please help barand.... Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201267 Share on other sites More sharing options...
willpower Posted March 6, 2007 Share Posted March 6, 2007 lmao you need to check if files uploaded are /image/jpeg, image/jpg or image/pjpeg That should catch all images of type jpg in IE, Firefox, and Opera. Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201273 Share on other sites More sharing options...
redarrow Posted March 6, 2007 Share Posted March 6, 2007 Heres a link to all mime types ok. http://www.webmaster-toolkit.com/mime-types.shtml $HTTP_POST_FILES <<<<<<<< is old why using this method? $_POST[' ']; <<<<<<<<<<<< new use this method i think? Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201277 Share on other sites More sharing options...
jonstu Posted March 6, 2007 Author Share Posted March 6, 2007 here are the changes till now that i made as u guys suggested: if($HTTP_POST_FILES['userfile']['type'] == 'image/jpg' || $HTTP_POST_FILES['userfile']['type'] == 'image/pjpeg' || $HTTP_POST_FILES['userfile']['type'] == 'image/jpeg') $original = imagecreatefromjpeg($HTTP_POST_FILES['userfile']['tmp_name']); is there any problem in this....? Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201279 Share on other sites More sharing options...
willpower Posted March 6, 2007 Share Posted March 6, 2007 with respect...you need to tell us...does it work...if not what error do you recieve??? Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201289 Share on other sites More sharing options...
jonstu Posted March 7, 2007 Author Share Posted March 7, 2007 okay, i tried replacing $HTTP_POST_FILES with $_POST but no luck. same error i am worried now... the code now is looking like: $resized = imagecreatetruecolor(450, 450); if($_POST['userfile']['type'] == 'image/png') $original = imagecreatefrompng($_POST['userfile']['tmp_name']); if($_POST['userfile']['type'] == 'image/jpg' || $_POST['userfile']['type'] == 'image/jpeg' || $_POST['userfile']['type'] == 'image/pjpeg') $original = imagecreatefromjpeg($_POST['userfile']['tmp_name']); if($_POST['userfile']['type'] == 'image/gif') $original = imagecreatefromgif($_POST['userfile']['tmp_name']); if($_POST['userfile']['type'] == 'image/bmp') $original = imagecreatefromwbmp($_POST['userfile']['tmp_name']); imagecopyresampled($resized, $original, 0, 0, 0, 0, $nwidth, $nheight, $owidth, $oheight); please help. ??? Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201302 Share on other sites More sharing options...
Barand Posted March 7, 2007 Share Posted March 7, 2007 $_POST won't do it with uploads. $HTTP_POST_FILES is deprecated, so use $_FILES. if(($_FILES['userfile']['type'] == 'image/jpeg') || ($_FILES['userfile']['type'] == 'image/pjpeg') || ($_FILES['userfile']['type'] == 'image/jpg')) $original = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201307 Share on other sites More sharing options...
Barand Posted March 7, 2007 Share Posted March 7, 2007 this works in FF and IE <?php if ($_FILES['userfile']) { $resized = imagecreatetruecolor(450, 450); if($_FILES['userfile']['type'] == 'image/png') $original = imagecreatefrompng($HTTP_POST_FILES['userfile']['tmp_name']); if(($_FILES['userfile']['type'] == 'image/jpeg') || ($_FILES['userfile']['type'] == 'image/pjpeg') || ($_FILES['userfile']['type'] == 'image/jpg')) $original = imagecreatefromjpeg($_FILES['userfile']['tmp_name']); if($_FILES['userfile']['type'] == 'image/gif') $original = imagecreatefromgif($_FILES['userfile']['tmp_name']); if($_FILES['userfile']['type'] == 'image/bmp') $original = imagecreatefromwbmp($_FILES['userfile']['tmp_name']); list($owidth, $oheight) = getimagesize($_FILES['userfile']['tmp_name']); $nwidth = $nheight = 450; imagecopyresampled($resized, $original, 0, 0, 0, 0, $nwidth, $nheight, $owidth, $oheight); header("content-type: image/jpeg"); imagejpeg($resized); imagedestroy($resized); imagedestroy($original); } ?> <form method='post' enctype='multipart/form-data'> <input type='file' name='userfile'> <input type='submit' name='action' value='Submit'> </form> Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201312 Share on other sites More sharing options...
jonstu Posted March 7, 2007 Author Share Posted March 7, 2007 It worked like a charm Barand.... I love You guys both of you barand and Willpower. Thankyou for saving my life. Love you dudes!! Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201334 Share on other sites More sharing options...
Barand Posted March 7, 2007 Share Posted March 7, 2007 From the list that redarrow posted it looks you need check for jpeg and pjpeg only. So my suggestion of using pjpeg was right, but I should have replaced the jpg, and not the jpeg, with pjpeg (which is why the others failed after the change.) Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201345 Share on other sites More sharing options...
willpower Posted March 7, 2007 Share Posted March 7, 2007 see he loves ya now....just like the rest of us! Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201350 Share on other sites More sharing options...
jonstu Posted March 7, 2007 Author Share Posted March 7, 2007 hahaha haaha .... I am going to tell my friends about you guys and this very helpful forum. Heartfelt Thanks again! Link to comment https://forums.phpfreaks.com/topic/41506-imagecopyresampled-problem/#findComment-201366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.