Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

image size validation


sharma.atul85

Recommended Posts

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

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

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

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

Archived

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

×
×
  • Create New...