Page 1 of 1

js validation for image ??

Posted: Thu Mar 01, 2007 4:17 am
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 !!

Posted: Thu Mar 01, 2007 8:00 am
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.

Posted: Fri Mar 02, 2007 8:25 am
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 !!

Posted: Fri Mar 02, 2007 8:29 am
by feyd
Google is pretty good at finding things..

http://www.google.com/search?q=javascri ... ad+preview

Posted: Fri Mar 02, 2007 8:32 am
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.