Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check the image size

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
Hi all. faq216-5781 tells me how to get the dimensions of an image, but is there a way via JS to get the image size? I'd like to check the image size before uploading the image. If the size is greater then, say, 1024 then throw an alert.

Thanks.

_____________________________
Just Imagine.
 
If you're talking about getting the image size before you even upload it from the server, then no - javascript will not be able to do this. Although I'm not familiar with any process that will do it, it's likely that you can achieve this with some PHP procedure or ASP.Net. You could then use an AJAX call to that server side procedure to get the dimensions without having to reload the page - so in that sense you could use javascript to get the data dynamically. But, honestly it's the PHP or ASP that's doing most of the work.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Yeah, that's what I thought. I know how to do this in Coldfusion, but wanted to see if I can achieve this w/o uploading the file. I figured since I can read the width and height of image from that FAQ above, maybe I can also get the image size.

Thanks.

_____________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top