vbMarkO Posted March 5, 2007 Share Posted March 5, 2007 I have a piece of code we are using to upload images to our site with. But I need this expaned and the guy I have helping me is not sure how to do it so can I get help. Here is what we need ... what would we need to add or do to allow this code to upload the images ... but resize them ... Here is how we need them resized ... This code needs to check to see if the height of the image is greater than the width ... if so then it also needs to check if the width is greater than 300pix if those conditions are true then it needs to reduce the image maintaining the aspect ratio but reducing the image width to 300pix. Now while checking if the Height is less than the width and the width is greater than 421pix it should reduce the image (maintaining the aspect ratio) to 421pix. If the height is equal to the width (square image) and the width is greater than 421pix it should reduce the image to 421 pix ... This is what I need .... can someone help .... is what I shared clear or confusing if confusing please ask away I really need this .... lets talk ... please here is the code we have ..... also you may know a way to simplify the logic .... [email protected] if ($_FILES["file"]["size"] < 20000000) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Uploaded: " . $_FILES["file"]["name"]. $i . "<br>"; while (file_exists("gallery/".$userdata['username']."/" . $_FILES["file"]["name"]. $i)) { $i++; } move_uploaded_file($_FILES["file"]["tmp_name"], "gallery/".$userdata['username']."/" . $_FILES["file"]["name"] . $i); echo "Stored in: " . "".$userdata['username']."/" . $_FILES["file"]["name"] . $i; echo '<br><br>'; } } Link to comment https://forums.phpfreaks.com/topic/41196-can-someone-help-with-this-code-please/ Share on other sites More sharing options...
AndyB Posted March 5, 2007 Share Posted March 5, 2007 This - http://fundisom.com/phparadise/php/image_handling/image_upload_and_resize - is working code that should give you ideas about how to solve your particular needs. Link to comment https://forums.phpfreaks.com/topic/41196-can-someone-help-with-this-code-please/#findComment-199582 Share on other sites More sharing options...
vbMarkO Posted March 5, 2007 Author Share Posted March 5, 2007 This - http://fundisom.com/phparadise/php/image_handling/image_upload_and_resize - is working code that should give you ideas about how to solve your particular needs. Thank you Andy we are going to give this a go later tonight will let you know, it does look like it might do what we need. Mark Link to comment https://forums.phpfreaks.com/topic/41196-can-someone-help-with-this-code-please/#findComment-199594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.