sharma.atul85 Posted May 22, 2009 Share Posted May 22, 2009 hello friends is there a way to restrict image size to a specific dimension like 800X1200. like at the time when admin upload an image for product then an error image is displayed saying this size of image is not supported . This is basically needed because am using code to resize image to three different sizes and resizing does not work properly when image size is greater than 1200X1200. Link to comment Share on other sites More sharing options...
steve_s Posted May 22, 2009 Share Posted May 22, 2009 hello friends is there a way to restrict image size to a specific dimension like 800X1200.like at the time when admin upload an image for product then an error image is displayed saying this size of image is not supported . This is basically needed because am using code to resize image to three different sizes and resizing does not work properly when image size is greater than 1200X1200. Admin-configuration-images see if anything in there, cant check myself right now im at work Link to comment Share on other sites More sharing options...
germ Posted May 23, 2009 Share Posted May 23, 2009 You can check the image size after it's uploaded with some code like this: if ( $image_size = @getimagesize( [color="#FF0000"][b]INSERT_PATH_TO_IMAGE_HERE[/b][/color] ) ) { if ( ( (int)$image_size[0] > 1200 ) || ( (int)$image_size[1] > 1200 ) ) { echo 'Image too large!'; } } If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
sharma.atul85 Posted May 23, 2009 Author Share Posted May 23, 2009 ok well this code might work but it will check image height width after submitting ..isn't there any other code which displays error the time image is uploaded like thru ajax Link to comment Share on other sites More sharing options...
germ Posted May 24, 2009 Share Posted May 24, 2009 There is no practical way to check the image size until AFTER it's uploaded. That would require "client side" code (some sort of active-x code) to be installed on the PC uploading the image. That's how a lot of infections are spread so most people who know anything at all about how things work would just "click off" and never return (I would as well to some site that wants me to install an active-x control - I wasn't born yesterday :huh: ). Stick with the "server side" approach. You and your customers will both be happier. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.