通过渐进增强在网络上上传大文件的最佳实践
我正在构建一个 HTML 表单,用户应该能够上传高达 ~100MB 的大文件。
我的用户可能来自任何地方,因此我不能指望宽带连接、现代浏览器或 Javascript/Flash 的可用性。对于确实拥有这些“额外功能”的用户,我想提供更好的体验,例如对流程的某种形式的反馈和灵活的形式。
我能想到的唯一可能出错的事情是服务器超时。但由于我从未构建过这样的功能我想知道其他人在该领域的最佳实践和最严重的问题是什么。
不完全相关,但后端是 PHP 的。
I'm building an HTML form with which the user should be able to upload big files up to ~100MB.
My users could be coming from anywhere so I can't count on a broadband connection, modern browser or availability of Javascript/Flash. For the users who do have these "extras" I'd like to offer a better experience like some form of feedback on the process and a flexible form.
The only thing that I can think of that can go wrong is a server timeout. But as I've never built functionality like this I'd like to know what other people's best practices and most serious problems in this area are.
Not entirely relevant but the backend is in PHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的后端是 PHP,那么除其他外,您还需要查看 upload_max_filesize。 此处涵盖了大多数配置问题。让您的应用程序验证运行时环境的参数并对其进行操作也是一个好主意,因为它可以提高容错能力。
我不建议在前端使用 Flash,因为它在处理大文件时往往会失败。如果没有 Javascript,除了浏览器的内置功能之外,根本不可能进行流程反馈。无需 JavaScript 即可提供的最佳体验是将文件上传表单放入 iframe 中,这样包含的页面就不会在上传过程中消失。
对于正常场景使用APC和轻量级AJAX的组合是一个不错的选择。 IBM 网站有一个关于该主题的实现演练。
If your backend is PHP then among other things you need to look at upload_max_filesize. Most configuration issues are covered here. Making your app verify and act on the parameters of runtime environment is also a good idea because it increases fault tolerance.
Using Flash on the frontend is something I would not recommend because it tends to fail with large files. And without Javascript, process feedback isn't possible at all except for the built-in features of a browser. The best experience you can provide without Javascript is by placing the file upload form into an iframe so that the containing page won't disappear during the upload.
For normal scenarios using a combination of APC and lightweight AJAX is a good choice. IBM website has an implementation walkthrough on the subject.