how to validate input type file using javascript for file type and size?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nNaveenpal
    New Member
    • Oct 2013
    • 1

    how to validate input type file using javascript for file type and size?

    how to validate input type file using javascript for file type and size?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    not as easy as you might wish.

    you have access to the file name through the input's value property, but there you can only check for the nominal extension (there is no guarantee that a .jpg file is actually a JPEG image, it could be just misnamed).

    the file size you could get if your broser supports the FileReader API.

    Comment

    Working...