benwhitmore Posted May 28, 2006 Share Posted May 28, 2006 Hi peeps,When I add a record to my database, I also have the option to upload an image associated with that record.How can I verify the images' size befor I upload it. Basically, the image must be less than 400px high or wide.Any feedback welcomeThanks Quote Link to comment https://forums.phpfreaks.com/topic/10648-verify-image-dimensions-befor-it-is-uploaded/ Share on other sites More sharing options...
AndyB Posted May 28, 2006 Share Posted May 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/10648-verify-image-dimensions-befor-it-is-uploaded/#findComment-39722 Share on other sites More sharing options...
benwhitmore Posted May 28, 2006 Author Share Posted May 28, 2006 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 againSOLVED Quote Link to comment https://forums.phpfreaks.com/topic/10648-verify-image-dimensions-befor-it-is-uploaded/#findComment-39734 Share on other sites More sharing options...
thehigherentity Posted May 29, 2006 Share Posted May 29, 2006 [!--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? Quote Link to comment https://forums.phpfreaks.com/topic/10648-verify-image-dimensions-befor-it-is-uploaded/#findComment-39892 Share on other sites More sharing options...
GingerRobot Posted May 29, 2006 Share Posted May 29, 2006 [a href=\"http://uk2.php.net/manual/en/function.imagecopyresized.php\" target=\"_blank\"]http://uk2.php.net/manual/en/function.imagecopyresized.php[/a] Quote Link to comment https://forums.phpfreaks.com/topic/10648-verify-image-dimensions-befor-it-is-uploaded/#findComment-39894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.