Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

JavaScript/Working with files

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

With pure HTML4 and pure JavaScript, there's really only one thing you can do with the users files: The server sends a Web page that includes a form something like this:RFC 1867, RFC 2388 <form action="/upload_handler" method="post"> <input type="file" /> </form> and then, the browser allows the user to select one file, and the browser uploads it -- without any JavaScript on the client being able to see any of that data or cancel the transmission or even show a progress bar. If you want JavaScript to know anything about the file before it is transmitted (for example, to immediately cancel the transmission of a large file rather than wait an hour for the file to be transmitted, then tell the user "File too large"; or to show a progress bar), you'll have to use something other than pure JavaScript on pure HTML4. Some popular options are:Getting upload file size before uploadIs it possible to use Ajax to do file upload?File API: W3C Last Call Working Draft 12 September 2013Reading files in JavaScript using the File APIs use a modern Web browser that supports the HTML5 File API. use Flash (perhaps a tiny flash utility like Gmail uses to draw a little progress bar) use a Java applet use an ActiveX control References