corillo181 Posted June 7, 2007 Share Posted June 7, 2007 so I'm working in a function that will upload a file is is 600px wide to a directory, now if the picture is greater than 600 i want it to make it 600 before uploading to the directory, after is uploaded i want it to make it a thumbnail. 150pxwide.. how can i best good about this with out creating 2 functions? this is what i have right now.. how can i fix this to make it what i want? function MakeItFit($picName,$galId,$tmpPath,$save,$descrive,$reSize){ //RENAME THE FOTO $remove=strstr($picName,'.'); $rand = mt_rand(0, 32); $number = md5($rand . time()).$remove; //Image width and height list($widthx,$heighty)=getimagesize($picture); //creating the make it fit picture for 600 width $srcImg=imagecreatefromjpeg("$tmpPath"); $ratio=$reSize/$widthx; $thumbHeight=$heighty*$ratio; $thumbImg=imagecreatetruecolor($resize,$thumbHeight); imagecopyresized($thumbImg,$srcImg,0,0,0,0,$resize,$thumbHeight,imagesx($srcImg),imagesy($srcImg)); imagejpeg($thumbImg,"$save/$number",100); //GETTING THE THUMBNAIL READY $getFixed="$save/$number"; if($getFixed){ list($widthT,$heightT)=getimagesize($getFixed); $path=$getFixed; $thumb=150; $srcThumb=imagecreatefromjpeg($path); $ratioT=$thumb/$widthT; $thumbheight=$heightT*$ratioT; $thumbTmg=imagecreatetruecolor($thumb,$thumbheight); imagecopyresized($thumbTmg,$srcThumb,0,0,0,0,$thumb,$thumbheight,imagesx($srcThumb),imagesy($srcThumb)); imagejpeg($thumbTmg,"$save/tn_$number",100); } } Quote Link to comment https://forums.phpfreaks.com/topic/54634-uploading-function/ 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.