April 23, 201214 yr Hey guys, how do I let the image type size restrict to it's width. Like, let's say a $_FILE["file"]["blabla"] must be under 300px width. If more then 300 px that it will get cancelled. How do perform this?
April 23, 201214 yr <?php list($width, $height) = getimagesize($uploadedfile); if($width > 9000){ echo "It's over 9000!"; } ?>
April 23, 201214 yr <?php // Open PHP tag! // Use getimagesize() to get the size of the uploaded image and set the height and width as $height and $width variables. Replace $uploadedfile with whatever variable your script is using to store the temporary image. list($width, $height) = getimagesize($uploadedfile); if($width > 9000){ // Perform a check to see if the width of the image is over a specific amount. I put 9000 in as it's a popular meme but you'll want to change that for 300. You'll also want to add in your own break point and error messaging for your script echo "It's over 9000!"; } //Close PHP tag! ?>
Create an account or sign in to comment