rik72 Posted October 16, 2007 Share Posted October 16, 2007 http://track9.info/info.php this is my phpinfo I'm using the following code; $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; } Can upload fine using firefox, but using internet explorer get this; Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/u2/ozaki12/html/track9/newt9/PHP_FILES/uploader.php on line 49 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/u2/ozaki12/html/track9/newt9/PHP_FILES/uploader.php on line 57 Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/ Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 can you post the form..as thats probably the problem, if it fails on some browsers Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371068 Share on other sites More sharing options...
le007 Posted October 16, 2007 Share Posted October 16, 2007 All I know is ImageMagik worked for a friend! Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371071 Share on other sites More sharing options...
rik72 Posted October 16, 2007 Author Share Posted October 16, 2007 <form action="index.php?pageid=31" method="post" enctype="multipart/form-data"> <p><b>Supported Formats: JPG,GIF ONLY!</b></p> <p> <input type="file" name="uploadfile"> </p> <p>Caption: <br> <input type="text" name="caption" size="20"></p> <p>Default:</p> <p>Yes<input type="radio" value="1" name="default" checked><br> No<input type="radio" value="0" name="default"></p> <p><b>Max File Size: 2mb.</b></p> <p>* This may take a long time! *</p> <p> <input type="submit" name="Upload" value="Upload Picture"/> </p> Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371077 Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 Hummm.. only problem i can see is an extra } at the end of the php script.. my test works fine.. <?php if(isset($_FILES)) { $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; } ?> <form method="post" enctype="multipart/form-data"> <p><b>Supported Formats: JPG,GIF ONLY!</b></p> <p> <input type="file" name="uploadfile"> </p> <p>Caption: <br> <input type="text" name="caption" size="20"></p> <p>Default:</p> <p>Yes<input type="radio" value="1" name="default" checked><br> No<input type="radio" value="0" name="default"></p> <p><b>Max File Size: 2mb.</b></p> <p>* This may take a long time! *</p> <p> <input type="submit" name="Upload" value="Upload Picture"/> </p> Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371087 Share on other sites More sharing options...
rik72 Posted October 16, 2007 Author Share Posted October 16, 2007 Yeah, thats for an if statement at the top making sure their is an active session, anyone else got any ideas how to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371110 Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 But it works.. ??? ooow Okay one thing.. try this switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/pjpeg": //Add this (photoshop jpeg) case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371115 Share on other sites More sharing options...
BlueSkyIS Posted October 16, 2007 Share Posted October 16, 2007 you may want to check to see what IE is providing here: $_FILES['uploadfile']['type'] Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371119 Share on other sites More sharing options...
rik72 Posted October 16, 2007 Author Share Posted October 16, 2007 Madtechie, you are once again a legend! it works again, cheers man! Quote Link to comment https://forums.phpfreaks.com/topic/73546-solved-image-upload-resize/#findComment-371137 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.