Thursday 15 September 2011

how validate file size using HTML and Javascript on client side -


How do I accept file sizes on the client side using Javascript? I am using type = file to select the file

Update 2013 as the Edit , the file API is supported in all major browsers, and in IE 10 version as

You If you still want to use the SWFUpload, you still need to support IE9 and below, although at this point it probably should be more of a fallback, because the html5 file app UI supports the mobile platform where SWFUpload can not access.

Update: Firefox can give its API to this

you can do this in Firefox

html:

  & lt; Form action = "method =" get "accept-charset =" utf-8 "& gt; & Lt; Input type = "file" name = "file" value = "" id = "file" & gt; & Lt; P & gt; & Lt; Input type = "submit" value = "continue & rarr;" & Gt; & Lt; / P & gt; & Lt; / Form & gt;  

Javascript:

  var filesize = document.forms [0]. File.files [0]. File Size  

If there is a way to do this in IE, then I do not know this. This probably includes active x or some other such nonsense.

EDIT: I found it in IE,

   

No comments:

Post a Comment