Solarpitch Posted September 14, 2007 Share Posted September 14, 2007 Guys, How do you simply resize an image when its uploaded. I would like to resize all images to 200 x 200. I am kinda resizing it at the moment but its loosing its quality. Oh .. and is there a way I can display the full size images on a new page when the user clicks on it? Quote Link to comment https://forums.phpfreaks.com/topic/69366-resizing-an-image-on-upload/ Share on other sites More sharing options...
MadTechie Posted September 14, 2007 Share Posted September 14, 2007 when you upload, resize one to 200x200 and another 100x100 (whatever) then use the smaller one for the thumbnail and the larger for when the user clicks on it, can you post some code please Quote Link to comment https://forums.phpfreaks.com/topic/69366-resizing-an-image-on-upload/#findComment-348519 Share on other sites More sharing options...
Solarpitch Posted September 14, 2007 Author Share Posted September 14, 2007 I am just using this basic upload script but I will modify it as I go. Where about would I need to ad the code to resize? if (($_FILES["userfile"]["type"] == "image/gif") || ($_FILES["userfile"]["type"] == "image/jpeg") || ($_FILES["userfile"]["type"] == "image/pjpeg") && ($_FILES["userfile"]["size"] < 20000)) { if ($_FILES["userfile"]["error"] > 0) { echo "Return Code: " . $_FILES["userfile"]["error"] . "<br />"; $execute = "no"; } else { echo "Upload: " . $_FILES["userfile"]["name"] . "<br />"; echo "Type: " . $_FILES["userfile"]["type"] . "<br />"; echo "Size: " . ($_FILES["userfile"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["userfile"]["tmp_name"] . "<br />"; if (file_exists("user_images/" . $_FILES["userfile"]["name"])) { echo $_FILES["userfile"]["name"] . " already exists. "; $execute = "no"; } else { move_uploaded_file($_FILES["userfile"]["tmp_name"], "user_images/" . $_FILES["userfile"]["name"]); echo "Stored in: " . "user_images/" . $_FILES["userfile"]["name"]; $target = "user_images/"; $target = $target . basename( $_FILES['userfile']['name']) ; } } } Quote Link to comment https://forums.phpfreaks.com/topic/69366-resizing-an-image-on-upload/#findComment-348523 Share on other sites More sharing options...
MadTechie Posted September 14, 2007 Share Posted September 14, 2007 resize code would be after this line $target = $target . basename( $_FILES['userfile']['name']) ; please see this thread as it will save me repeating myself Quote Link to comment https://forums.phpfreaks.com/topic/69366-resizing-an-image-on-upload/#findComment-348527 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.