开发者

Different approaches for File upload using Ajax

To upload the file using JavaScript generally iFrame approach is used in which Hidden iframe is maintained and then the file is uploaded using the iframe.

However it is said not to be reliable method for the file upload and Flash is used for this purpose. So i am not clear how this is done? I mean by Flash and JavaScript together ?

Also i would like to know if in case there are any other approaches for file upload? like on client side read the file convert into binary data and then send it acro开发者_开发技巧ss or something like that.

Thanks all,


So i am not clear how this is done? I mean by Flash and JavaScript together ?

With ExternalInterface (or, more usually, through a pre-rolled Flash object such as YUI Uploader which does all that for you).

i would like to know if in case there are any other approaches for file upload?

Java. ActiveX.

They use the same principles as Flash, but have weaker support.

like on client side read the file convert into binary data

The file is already binary data (unless it is a text file), but read it … how? JavaScript doesn't have access to the filesystem in a standard security context.


There is nothing inherently wrong with the iframe approach. Flash based uploading just adds more possibilities, like showing an upload bar, client side image resizing, better and more reliable filtering options (File type / size) and so on.

Flash based uploaders allow the circumvention some of the restrictions that <input type=file> elements have, for example it is possible to fully style the "upload" button.

Check out one of the ready-made solutions to see how they work. My favourites are

  • SWFUpload
  • Uploadify
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜