js validation for image ??

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

js validation for image ??

Post by PHPycho »

i am trying to make the javascript validation for images..
For example i tried to upload the file "c:\folder\file.exe"
It should check the extension , if the extension is not image type
should give alert..

what i want?

1> i want to know if there is any function in javascript
that reads the extension of full path like "c:\folder\file.exe"
2> file size

Thanks in advance to all of you !!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The extension has nothing to do with the data it holds. Even then, Javascript is not guaranteed to be enabled on the client. Just check it server-side.
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

Pardon again..
is it possible to show the upload preview while uploading with javascript ?

If Yes i am eagerous to know the solution..
Thank you !!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Google is pretty good at finding things..

http://www.google.com/search?q=javascri ... ad+preview
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Considering the image being uploaded is on the client's computer, you could dynamically display it from their computer. Just trigger it to display whatever's written in the uploading field by setting the image's src to "file///" + whatever's in the field onChange. I'm not to sure of the security on that method, but in theory it should work as long as the user inputs the filename through the browse button.
Post Reply