如何使用ajax上传文件,比如gmail做什么?

时间:2022-08-25 16:25:45

I know how to POST/GET text values with ajax,

我知道如何使用ajax发布/获取文本值,

but never know how to upload files with ajax.

但是永远不知道如何用ajax上传文件。

Can someone just give a simple demo here?

有人能在这里做个简单的演示吗?

4 个解决方案

#1


4  

GMail is actually using Flash for uploading files now... You could try looking into something like SWFUpload.

GMail实际上正在使用Flash来上传文件。您可以尝试查看SWFUpload之类的东西。

#2


0  

Ajax could certainly upload files by posting a HTML form with a input type="file" in it.

Ajax当然可以上传带有输入类型="file"的HTML表单。

Some links to get you started:

一些让你开始的链接:

http://www.webtoolkit.info/ajax-file-upload.html

http://www.webtoolkit.info/ajax-file-upload.html

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

Depending on the server/server side language you could probably send some kind of progress info to the client to render as a progress bar.

根据服务器/服务器端语言的不同,您可以向客户端发送某种进度信息,作为进度条进行呈现。

#3


0  

Check out this Ajax upload scripts, it has examples in Php and .Net. The basic idea behind the script is that you have to create an iFrame to handle this.

看看这个Ajax上传脚本,它有Php和。net中的示例。脚本背后的基本思想是必须创建一个iFrame来处理这个问题。

#4


0  

The YUI uploader is a flash based uploader that is designed to be very easy to integrate into javascript, with minimal knowledge of flash.

YUI上传者是一个基于flash的上传者,它被设计成非常容易集成到javascript中,并且几乎不了解flash。

If you want a progress bar, I believe a pure javascript solution would require a server side piece to send back the current completion percentage via ajax, which would add quite a bit of complexity compared to a flash solution.

如果您想要一个进度条,我认为纯javascript解决方案需要一个服务器端部分通过ajax发送当前完成百分比,与flash解决方案相比,这将增加相当大的复杂性。

#1


4  

GMail is actually using Flash for uploading files now... You could try looking into something like SWFUpload.

GMail实际上正在使用Flash来上传文件。您可以尝试查看SWFUpload之类的东西。

#2


0  

Ajax could certainly upload files by posting a HTML form with a input type="file" in it.

Ajax当然可以上传带有输入类型="file"的HTML表单。

Some links to get you started:

一些让你开始的链接:

http://www.webtoolkit.info/ajax-file-upload.html

http://www.webtoolkit.info/ajax-file-upload.html

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

Depending on the server/server side language you could probably send some kind of progress info to the client to render as a progress bar.

根据服务器/服务器端语言的不同,您可以向客户端发送某种进度信息,作为进度条进行呈现。

#3


0  

Check out this Ajax upload scripts, it has examples in Php and .Net. The basic idea behind the script is that you have to create an iFrame to handle this.

看看这个Ajax上传脚本,它有Php和。net中的示例。脚本背后的基本思想是必须创建一个iFrame来处理这个问题。

#4


0  

The YUI uploader is a flash based uploader that is designed to be very easy to integrate into javascript, with minimal knowledge of flash.

YUI上传者是一个基于flash的上传者,它被设计成非常容易集成到javascript中,并且几乎不了解flash。

If you want a progress bar, I believe a pure javascript solution would require a server side piece to send back the current completion percentage via ajax, which would add quite a bit of complexity compared to a flash solution.

如果您想要一个进度条,我认为纯javascript解决方案需要一个服务器端部分通过ajax发送当前完成百分比,与flash解决方案相比,这将增加相当大的复杂性。