techker Posted March 19, 2010 Share Posted March 19, 2010 Hey guys i have an uploader and resizer script that works a1.the only thing is i would like to resize the original image. see now it resizes for a thumbnail and uplloads it to the image/thumb and the original to image/big //load the config file include("config.php"); //if the for has submittedd if (isset($_POST['upForm'])){ $file_type = $_FILES['imgfile']['type']; $file_name = $_FILES['imgfile']['name']; $file_size = $_FILES['imgfile']['size']; $file_tmp = $_FILES['imgfile']['tmp_name']; $Box = $_POST['Box']; $ID = $_GET['ID']; //check if you have selected a file. if(!is_uploaded_file($file_tmp)){ echo "Error: Please select a file to upload!. <br>--<a href=\"$_SERVER[php_SELF]\">back</a>"; exit(); //exit the script and don't do anything else. } //check file extension $ext = strrchr($file_name,'.'); $ext = strtolower($ext); if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { echo "Wrong file extension. <br>--<a href=\"$_SERVER[php_SELF]\">back</a>"; exit(); } //get the file extension. $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; //create a random file name $rand_name = md5(time()); $rand_name= rand(0,999999999); //get the new width variable. $ThumbWidth = $img_thumb_width; //keep image type if($file_size){ if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){ $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } //list width and height and keep height ratio. list($width, $height) = getimagesize($file_tmp); $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; }else{ $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //function for resize image. if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //save image ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); //print message // echo "<br>Image Thumb: <a href=\"$path_thumbs/$rand_name.$file_ext\">$path_thumbs/$rand_name.$file_ext</a>"; } //upload the big image move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext"); echo "<meta http-equiv=Refresh content=1;url=insert.php?ID=$ID&Name=$rand_name.$file_ext>"; } ///////////////////////////insert part added echo" </body> </html>"; ?> Is it possible? Quote Link to comment Share on other sites More sharing options...
Ruzzas Posted March 20, 2010 Share Posted March 20, 2010 Sorry you make no sense, can you type it out again? Quote Link to comment Share on other sites More sharing options...
techker Posted March 20, 2010 Author Share Posted March 20, 2010 it uploads the file and creats a thumbnail. it keeps the size of the original and uploads it to images/big and resizes it and uploads the resized image to images/thumbs Now.i want to make the Big images a diffrent size. Quote Link to comment 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.