上传前警告用户文件太大

发布于 2024-09-16 05:39:02 字数 235 浏览 5 评论 0原文

为了增加用户体验,我想在发送整个文件之前警告用户文件太大(假设> 8M)(由于大小和客户端连接,这可能需要一些时间)。所有类型的字段都可以在客户端进行“预先验证”,以获得更好的用户体验,但我陷入了文件大小问题。

这个问题有解决办法吗?

[编辑] 我也对 APC for PHP 持开放态度,它具有 rfc 1867 功能。我不确定如果我们检测到大小太大,是否可以取消表单上传。如果有人告诉我如何做,我当然会奖励赏金。

To increase user experience, I would like to warn the user that the file is too big (let's say > 8M) before sending the whole file (which may take some time due to the size and the client connection). All kind of fields can be "pre-validated" client-side for a better user experience, but I'm stuck on the file size problem.

Is there a solution to this problem?

[edit] I'm also open to APC for PHP, which features the rfc 1867. I'm not sure if it's possible to cancel the form upload if we detect the size is too big. I certainly will award bounty if someone show me how to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

原来是傀儡 2024-09-23 05:39:03

这个基于 Flash 的上传器怎么样? http://swfupload.org/

这似乎很引人注目

  • 如果 Flash 或 javascript 不可用,则可以优雅地降级为正常的 HTML 上传表单
  • 控制上传开始前的文件大小

由于它是开源的,如果您愿意,您可以将优雅降级与其他仅 HTML5 和 IE 的解决方案结合起来,以覆盖大多数浏览器安装:
http://code.google.com/p/swfupload/

How about this Flash based uploader? http://swfupload.org/

This seems compelling

  • Degrades gracefully to normal HTML upload form if Flash or javascript is unavailable
  • Control filesize before upload starts

Since it's open source if you were keen you could combine the graceful degradation with the other HTML5 and IE only solutions to cover most browser installs:
http://code.google.com/p/swfupload/

沧桑㈠ 2024-09-23 05:39:03

您可以在 IE 9 或更早版本以外的新浏览器中使用文件 API。我通过谷歌搜索找到了本教程: http://www.html5rocks.com/tutorials/file /dndfiles/

此外,MDC 参考位于:https://developer.mozilla .org/en/DOM/File

不幸的是,我不认为所有版本的 IE 都有这种方法。 Flakron 的答案听起来像是 6 和 7,但我不确定 8 并且我不熟悉 IE API。您可能需要使用基于插件的上传程序(Flash、Silverlight 或 Java)。

You can use the File API in new browsers that aren't IE 9 or earlier. I found this tutorial with some Googling: http://www.html5rocks.com/tutorials/file/dndfiles/

Also, the MDC reference is here: https://developer.mozilla.org/en/DOM/File

Unfortunately I don't think there is a way in all versions of IE. Flakron's answer covers 6 and 7 it sounds like, but I'm not sure about 8 and I'm not familiar with the IE API. You probably would need to go with a plugin based uploder (Flash, Silverlight, or Java).

娇妻 2024-09-23 05:39:03

这是一个简单的解决方案

http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html

更改它以满足您的需求

,但要注意有报道称它在某些浏览器中不起作用,可能需要进行一些更改。

Here is a simple solution to that

http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html

change it to match your needs

but beware it has been reported that it doesn't work in some browsers, it might need some changes.

江南月 2024-09-23 05:39:03

这个问题有解决办法吗?

我认为您最终会后悔选择“太大”的大小来警告,因为传输速度才是吞吐量的真正决定因素。

最好简单地显示预计完成时间以及取消选项。进度温度计也很好。这样,用户可以决定是否需要太长时间,无论文件大小或连接速度如何,并且当过去的大上传变成未来的小任务时,您永远不必返回并修改您选择的“太大”限制不可避免的性能提升。

Is there a solution to this problem?

I think you'll end up regretting choosing a "too big" size to warn about, because transfer speed is the real determination of throughput.

It's better to simply show the estimated time to completion along with a cancel option. A progress thermometer is nice too. That way, the user can decide if it will take too long, regardless of file size or connection speed, and you'll never have to go back and modify your chosen "too big" limit when past big uploads turn into future minor tasks due to the inevitable performance increases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文