shadiadiph Posted April 15, 2011 Share Posted April 15, 2011 Sorry bit rusty but been trying this for hours I upload an image no errors are showing i upload a jpg file and it saves to the server fine but its saving the original size not the new resized image size any ideas?? if (isset ($_FILES['file'])) { $tmp_name = $_FILES["file"]["tmp_name"]; $file_type = $_FILES["file"]["type"]; $fileatt_name = $_FILES["file"]["name"]; if ($file_type=="image/pjpeg" OR $file_type=="image/jpeg" OR $file_type=="image/jpg") { $src = imagecreatefromjpeg($tmp_name); } // END if ($file_type=="image/pjpeg" OR $file_type=="image/jpeg" OR $file_type=="image/jpg") if ($file_type=="image/png" OR $file_type=="image/x-png") { $src = imagecreatefrompng($tmp_name); } // END if ($file_type=="image/png" OR $file_type=="image/x-png") if ($file_type=="image/gif") { $src = imagecreatefromgif($tmp_name); } // END if ($file_type=="image/gif") list($width,$height)=getimagesize($tmp_name); $width = $width; $height = $height; $newwidth = "200"; $newheight = "200"; $ratio=''; if($width==$height) { $newwidth = "200"; $newheight = "200"; } if($width>$height) { $ratio=($height/$width); $newwidth = "200"; $newheight = ($newwidth*$ratio); } if($width<$height) { $ratio=($width/$height); $newheight = "200"; $newwidth = ($newheight*$ratio); } $tmp = imagecreatetruecolor($newwidth, $newheight); $new=imagecopyresampled($tmp, $src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = "./yxy/". $fileattt_name; imagejpeg($tmp,$filename,100); imagedestroy($tmp); } Quote Link to comment https://forums.phpfreaks.com/topic/233824-image-is-not-resizing/ Share on other sites More sharing options...
blacknight Posted April 15, 2011 Share Posted April 15, 2011 befor droping the image in to a dir try just making in in what ever dir the script is in ... $filename = $fileattt_name; Quote Link to comment https://forums.phpfreaks.com/topic/233824-image-is-not-resizing/#findComment-1202189 Share on other sites More sharing options...
shadiadiph Posted April 16, 2011 Author Share Posted April 16, 2011 works the same but it's saving the real sized image Quote Link to comment https://forums.phpfreaks.com/topic/233824-image-is-not-resizing/#findComment-1202215 Share on other sites More sharing options...
shadiadiph Posted April 16, 2011 Author Share Posted April 16, 2011 solved it must have been tired last night Quote Link to comment https://forums.phpfreaks.com/topic/233824-image-is-not-resizing/#findComment-1202217 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.