通过AJAX中的JQuery文件上传 [英] File Upload via AJAX within JQuery

查看:159
本文介绍了通过AJAX中的JQuery文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的JQuery的AJAX。我想实现一个文件上传使用jQuery的。 才有可能使使用jQuery,AJAX的一个FileUpload并将其发送到Servlet的可使用Apache的文件共享空间上传的文件。任何人都可以请建议我如何进一步进行呢?

I am new to JQuery AJAX . I want to implement a file upload using a jquery. Will it be possible to make a fileupload with JQuery,AJAX and send it to Servlet which can use apache file commons to upload the file. Can anyone please advice me how to proceed further?

谢谢, Deepthi。

Thanks, Deepthi.

推荐答案

阿贾克斯在传统意义上是XMLHtt prequest,它不允许你连接code和发送本地文件到服务器。

Ajax in the traditional sense is XMLHttpRequest, which does not allow you encode and send local files to a server.

在做,通过Ajax的方式上传的常用方法,就是无论是使用的Flash SWF处理上载在同一页上,或使用具有一种无形的1x1的目标形式的 IFRAME 。你有一些JavaScript显示上传微调或两者。之后,文件上传,使服务器返回一些JavaScript来的iframe像

The common ways of doing uploading through "ajax" means, is to either use a Flash swf to handle the uploading on the same page, or to use a form that has a target of an invisible 1x1 iframe. You have some Javascript show a uploading spinner or whichever. After the file is uploaded, make the server return some Javascript to the iframe like

<script type="text/javascript">
top.MyProject.doneUploading();
</script>

将允许您调用JavaScript在常规页面。为了让这工作,虽然,您必须确保在iframe提交到上面的文件位于同一域中。

top will allow you to call Javascript in the regular page. In order for that to work though, you must make sure the iframe has submitted to the same domain that the top document is located at.

这篇关于通过AJAX中的JQuery文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆