pranshu82202 Posted August 31, 2011 Share Posted August 31, 2011 Well i have a php script which i use to upload jpg or gif images only... I want that whenever user uploads an image of any resolution my script transforms it to 100*100 resolution.. What should i do... Here is my PHP Script... $_FILES["file"]["name"]=$_SESSION['id'].".jpg"; if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { /* echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; */ if (file_exists("upload/" . $_FILES["file"]["name"])) { echo " You have already uploaded your profile pic..."; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); //rename("/upload/" . $_FILES["file"]["name"], "/upload/" . $_SESSION['id'] ); $_SESSION['result']="PROFILE SETUP SUCCESSFULL"; header('location:members.php'); } } } else { echo "Invalid file"; } } Link to comment https://forums.phpfreaks.com/topic/246140-uploading-image/ Share on other sites More sharing options...
requinix Posted August 31, 2011 Share Posted August 31, 2011 What should i do... 1. Go to http://www.google.com. 2. Enter search terms such as "php thumbnail image" (which is what you want to do, after all) 3. Search 4. ??? 5. Profit! Link to comment https://forums.phpfreaks.com/topic/246140-uploading-image/#findComment-1264075 Share on other sites More sharing options...
Cagecrawler Posted August 31, 2011 Share Posted August 31, 2011 You need to look at the GD image functions: imagecreatefromjpeg or imagecreatefromgif imagecopyresampled imagejpeg or imagegif Link to comment https://forums.phpfreaks.com/topic/246140-uploading-image/#findComment-1264077 Share on other sites More sharing options...
jcbones Posted September 1, 2011 Share Posted September 1, 2011 A class that is a few years old, but handles this kind of stuff with ease (especially to the user), is called SimpleImage. I have used it in the past, and have recommended it before. I think it might could help you do what you are trying to do. Link to comment https://forums.phpfreaks.com/topic/246140-uploading-image/#findComment-1264138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.