简体   繁体   English

使用mootools异步上传文件?

[英]Asynchronous file upload with mootools?

At the moment I am doing file uploading with asp.net: 目前,我正在使用asp.net上传文件:

<asp:FileUpload ID="Upload" runat="server" /> <!-- HTML -->
Upload.PostedFile.SaveAs(physicalPath + "newAvatarTemp.png"); // codebehind

However, I hate it when pages are refreshed for stuff like this. 但是,当页面刷新时,我讨厌这样。 Really, I want to be able to do something with javascript. 确实,我希望能够使用javascript做某事。 Looking around on the web, people seem to be using SWF + javascript, but I really want to avoid using flash. 在网上浏览时,人们似乎正在使用SWF + javascript,但是我真的想避免使用Flash。 I really want something that feels nice, like the gmail file uploader. 我真的想要一种感觉不错的东西,例如gmail文件上传器。

How should I go about doing this? 我应该怎么做呢? Or is it not possible ( I read some posts hinting that file uploading can't be done with ajax). 还是不可能(我读过一些帖子暗示无法使用Ajax上传文件)。 If this is the case, how does gmail do it? 如果是这种情况,gmail怎么做?

If its not possible to do this with ajax, what are other solutions to make my file upload feel better? 如果无法使用Ajax做到这一点,还有什么其他解决方案可以使我的文件上传感觉更好? I'm fairly new with web technologies, so maybe I am missing something simple. 我是Web技术的新手,所以也许我缺少一些简单的东西。

The trick is to actually use an <iframe> to hide the upload in a new window. 诀窍是实际使用<iframe>在新窗口中隐藏上载内容。 The new AJAX functions will allow you to do file upload straight from an AJAX call, but not all browsers support that yet, so you can use the <iframe> technique as a fallback . 新的AJAX功能将允许您直接通过AJAX调用进行文件上传,但并非所有浏览器都支持该功能,因此您可以使用<iframe>技术作为后备

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM