Jump to content

Verify image dimensions befor it is uploaded


benwhitmore

Recommended Posts

That's simple - you can't determine an image's size unless you have already uploaded it.

You have these choices:

Upload the image and if it's oversized do not add image data to the database. The uploaded image can be left in the tmp folder which empties itself at the end of a browser session.

Upload the image and re-size it so its dimensions suit your requirements, then save the image and image data.
Link to comment
Share on other sites

great, thanks for the heads up.

it works now, i done it this way incase anyone was wondering....

[code]
foreach($_FILES as $image=>$image_array){
if (is_uploaded_file($image_array['tmp_name'])){

list($width_orig, $height_orig) = getimagesize($image_array['tmp_name']);

if ($width_orig>400 || $height_orig>400){
echo "That is too big my friend, choose a pic smaller than 400px wide or 400px high";
}

}
}
[/code]

thanks again

SOLVED
Link to comment
Share on other sites

[!--quoteo(post=377846:date=May 28 2006, 10:11 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 28 2006, 10:11 AM) [snapback]377846[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Upload the image and re-size it so its dimensions suit your requirements, then save the image and image data.
[/quote]

Just wondering, but how do you change the size of an image once it has been uploaded?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.