Gossamer Forum
Home : General : Internet Technologies :

Check and image dimensions, before upload?

Quote Reply
Check and image dimensions, before upload?
Hi. I'm not even sure if this is possible.. but its worth asking :)

I am trying to validate that an image is no larger than xxx by xxx pixels in Javascript (before uploading).

I had a look on Google, but it all seems to be related to ASP and PHP checking?

http://www.google.com/...rowser+before+upload

Does anyone know if this is possible, and if so, does anyone have any pointers?

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Check and image dimensions, before upload? In reply to
Hi,

You can't. The security settings in the browser prevent you from accessing the contents of a file field. It needs to be checked server side.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Check and image dimensions, before upload? In reply to
Thanks for confirming that. At least I'm not gonna spend another couple of hours looking at how to do something, thats impossible :P

BTW, what are you doing up at this time of day? Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Check and image dimensions, before upload? In reply to
Hello Andy, Have attached a very quick and dirty Javascript
image size thingy for the file upload attribute.

-- obviously this will only work if you select an image from the browse button.

You might change the test of the image height and width for an onSubmit
returning true if under size and false if over size, etc ....

Have only tried on IE 6.0 on XP.

have a go

thanks cornball
Quote Reply
Re: [Andy] Check and image dimensions, before upload? In reply to
Hello Andy, Version 2 of checking an Image size before uploading.

Only tested on IE version 6 and XP

You still have to check on the server side as Javascript can be turned off on the client side.

thanks cornball.
Quote Reply
Re: [cornball] Check and image dimensions, before upload? In reply to
Hello a small goof fixed on other file types selected.

See new ImageSizesV3.html attached.

It is only a JS toy after all and not an Atom bomb.

thanks cornball
Quote Reply
Re: [cornball] Check and image dimensions, before upload? In reply to
Goof goof goof

Version 4 covers case on file ext , so JpG or JPG or jpg are okay.

thanks cornball
Quote Reply
Re: [cornball] Check and image dimensions, before upload? In reply to
Thanks... that seems to work great :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!