I was working on Ajax web application last time, and realized that we cannot upload a File using Ajax. I saw it on many sites, and tutorials saying we cannot upload a file using Ajax, for that we need to use Flash or iframe's etc..to do so. But why it is not possible? In future will that be possible?
|
|
Uploading files is deliberately hard to avoid security leaks. If you could do that with a few lines of JavaScript, evil websites could secretly upload local files. For that reason, it must be done through a form, the user must see a file upload control, must choose the file by himself. After that, the form has to be submitted, and that's normal HTTP transfer, not Ajax, because XMLHttpRequest doesn't support multipart/form-data uploads. Therefore the iframes to gather the result. But those iframes can be invisible, and they can be processed after loading. |
|||||||||||||
|
|
Well you can do that right now using JQuery Form Plugin. Have a look at the demos here - http://jquery.malsup.com/form/ |
|||||||||||
|
|
Upload support is part of the XMLHttpRequest Level 2 Working Draft. It's currently supported by Safari and Chrome, and should be supported later in the year by new versions of Firefox and Internet Explorer. |
|||
|
|
