Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (26 sloc) 1.13 KB
layout title date tags
post
File upload
2012-02-22 21:00:00 +0100
javascript

The alternatives right now (2012-02-22):

  1. Standard html: File select together in a form that is submitted to a page. (firefox, chrome, IE)
  2. Iframe hack: File select together with hidden iframe used to upload file. (firefox, chrome, IE)
  3. Flash (all flash enabled browsers)
  4. FileReader  (firefox, chrome)
    1. Drag and drop together with FileReader and ajax post. 
    2. File select together with FileReader and ajax post.
When building ordinary web applications then the first alternative is definitely the best. It's simple and works well. If you are building a more javascript intense application you are in a different mess. If you are supporting IE 7-9 then alternative 2 and 3 is what you are looking for. To enable the best experience you could sniff if the browser handles FileReader (since IE10 might support it) and enable a better experience in that case.

Note: I've only considered firefox, chrome and IE.