PDA

View Full Version : js validation for image?



PHPycho
Mar 1st, 2007, 10:08 AM
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 !!

chump2877
Mar 1st, 2007, 11:29 AM
For #1,

It's probably easiest to just split the file path by a period, so:


var file = "c:\folder\file.exe";
var fileParts = file.split(".");
var fileExtension = fileParts[fileParts.length-1];

For #2,

I don;t know (with JS), and it seems like this is more suited to server-side validation...

PHPycho
Mar 2nd, 2007, 02:27 PM
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 !!

glenngv
Mar 2nd, 2007, 04:30 PM
http://www.codingforums.com/showthread.php?t=30865