Jump to content

Can someone help with this code please


vbMarkO

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.