[thelist] File upload filter (via Javascript) before submitting aform?

Jeff Howden jeff at jeffhowden.com
Wed Dec 24 02:02:41 CST 2003


> From: SED
> Is there any way to test (and filter) the file input
> before submitting the form? I want to allow the user
> to upload image files within certain size and formats
> e.g. 200k jpeg or gif. However, the JavaScript objects
> for the file input seems to be very limited (probably
> for security reasons). I know how to get the filename
> and test if it has correct extension but I want to get
> MIME type and size to - is it possible?

you can't get mime type, but on images in a roundabout fashion you can get
width, height, and file size.  on other filetypes, getting anything but the
filename is practically impossible.  i'd go into an explanation of how it's
done, but it's extremely complicated and fraught with pitfalls.

email me offlist if you really want to go down that road.


Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/

More information about the thelist mailing list