Skip to content Skip to sidebar Skip to footer

Javascript/ajax File Uploading

I need to upload a local file to server with javascript/AJAX. The problem is how can I select a file and read it into byte array? PS: I can't use HTML form to do the file uploadin

Solution 1:

With HTML5, there is the FileReader API. It allows you to read the files that your users have selected. The other day I build a CSV parser using HTML5 and JS only. It wasn't hard at all either.

Since it is a newer api, it isn't well supported. Check out the support here. http://caniuse.com/#search=filereader

If you don't want to do that, then you will need to do the flash solution that Benjamin has suggested.

If you more info, go here. Pretty awesome!!! https://developer.mozilla.org/en/DOM/FileReader

Solution 2:

You either use a Iframe with a HTML form or flash (theres no way to convert a file to a byte array using javascript)

http://www.uploadify.com/faqs/ (javascript and flash)

http://aquantum-demo.appspot.com/file-upload (javascript and iframe)

Please note that flash will not work on ipad, iphone and all other mobile apple

Solution 3:

use this plugin it just worked for me . http://hayageek.com/docs/jquery-upload-file.php And the fun part it takes all files

Post a Comment for "Javascript/ajax File Uploading"