使用 Flex 同时上传多个文件 [英] Uploading multiple files simultaneously with Flex

查看:25
本文介绍了使用 Flex 同时上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个灵活的上传器,用户可以在其中选择多个文件.

I have been working on a flex uploader, where the user can select multiple files.

将文件上传到队列中(一次一个)时效果很好,但是一旦我尝试让它一次上传 2 个文件,我就会遇到问题.

It works fine when the files are uploaded in a queue (one at a time), however as soon as I try to have it upload 2 files at once I run into issues.

文件似乎经常被锁定,要么保持在 1% 直到所有其他文件上传,要么根本不完整.一次上传的文件绝不会超过一个.

It seems that files will often lock up, and either stay at 1% until every other file is uploaded, or just not complete at all. There is never more than one file uploading at a time.

在 Flex 中一次对多个文件调用 .upload 有什么问题吗?

Is there some issue with calling .upload on multiple files at once in Flex?

推荐答案

不幸的是,每个主机的浏览器限制为 2 个(取决于浏览器)活动连接.这意味着一次只有 2 个上传处于活动状态,而另一个将排队.现在这通常不会成为真正的问题,但是当上传的文件非常大时,其他上传将超时,即使它们没有开始.每 2 次上传使用子域(upl1.mydomain.com、upl2.mydomain.com)有一种解决方法,我没有测试过,但它应该可以解决问题.

Unfortunately it's a browser limitation of 2 (depending on browser) active connections per host. Meaning only 2 uploads will be active at a time, while the other will be queued. Now this normally wouldn't really be a problem but when the uploaded files are pretty large, the other uploads will time out, even though they didn't start. There's a workaround in using subdomains every 2 uploads (upl1.mydomain.com, upl2.mydomain.com) that I didn't get to test but it should do the trick.

参考:http://anirudhs.chaosnet.org/blog/2008.06.17.htmlhttp://www.ajaxperformance.com/2006/12/18/circumventing-browser-connection-limits-for-fun-and-profit/(实际上可以从第一个链接获得).

References: http://anirudhs.chaosnet.org/blog/2008.06.17.html and http://www.ajaxperformance.com/2006/12/18/circumventing-browser-connection-limits-for-fun-and-profit/ (which you can get to from the first link actually).

此外,您可能无法在 Flash 中对上传进行排队,因为安全模型需要在单击鼠标时调用(FileReference 的)上传方法.

Also, you probably won't be able to queue the uploads in flash, because the security model requires upload method (of the FileReference) to be called as a result of a mouse click.

这篇关于使用 Flex 同时上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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