从浏览器上传多个文件的最佳方式 [英] Best way to upload multiple files from a browser

查看:24
本文介绍了从浏览器上传多个文件的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网络应用程序.有一处用户可以使用 HTTP 协议上传文件.可以选择经典的 HTML 文件上传控件和 Java 小程序来上传文件.

I'm working on a web application. There is one place where the user can upload files with the HTTP protocol. There is a choice between the classic HTML file upload control and a Java applet to upload the files.

经典的 HTML 文件上传不是很好,因为您一次只能选择一个文件,并且在实际上传过程中很难获得任何进度指示(我最终使用计时器刷新进度指示器与数据通过 AJAX 调用从服务器获取).优点:它始终有效.

The classic HTML file upload isn't great because you can only select one file at a time, and it's quite hard to get any progress indication during the actual upload (I finally got it using a timer refreshing a progress indicator with data fetched from the server via an AJAX call). The advantage: it's always working.

使用 Java 小程序我可以做更多的事情:一次选择多个文件(甚至是一个文件夹)、压缩文件、获得真正的进度条、将文件拖放到小程序上等等...
但是有一些缺点:

With the Java applet I can do more things: select multiple files at once (even a folder), compress the files, get a real progress bar, drag'n'drop files on the applet, etc...
BUT there are a few drawbacks:

  • 让它在 Mac Safari 和 Mac Firefox 上正常工作是一场噩梦(感谢 Liveconnect)
  • UI 并不完全是原生 UI,有些人会注意到
  • 小程序没有应有的响应(可能是我的错,但在我看来一切正常)
  • Java UrlConnection 类在使用 HTTPS 时存在错误,因此我使用 Apache 通用 HTTP 客户端来进行实际的 HTTP 上传.这是一个相当大的包并且减慢了 .jar 文件的下载速度
  • Apache 通用 HTTP 客户端有时无法通过代理
  • Java 运行时非常大
  • it's a nightmare to get it to work properly on Mac Safari and Mac Firefox (Thanks Liveconnect)
  • the UI isn't exactly the native UI and some people notice that
  • the applet isn't as responsive as it should (could be my fault, but everything looks ok to me)
  • there are bugs in the Java UrlConnection class with HTTPS, so I use the Apache common HTTP client to do the actual HTTP upload. It's quite big a package and slows down the download of the .jar file
  • the Apache common HTTP client has sometimes trouble going through proxies
  • the Java runtime is quite big

我一直在维护这个 Java 小程序,但现在我厌倦了所有的缺点,并考虑编写/购买一个全新的组件来上传这些文件.

I've been maintaining this Java applet for a while but now I'm fed up with all the drawbacks, and considering writing/buying a completely new component to upload theses files.

问题

如果您有以下要求:

  • 通过 HTTP 或 HTTPS 从浏览器轻松上传多个文件
  • 压缩文件以减少上传时间
  • 上传应适用于任何平台,具有原生 UI
  • 必须能够上传大文件,至少可达 2GB
  • 您可以全权决定技术

您会使用什么技术/组件?

  • 在组件上拖放文件将是一个很好的加分项.
  • 看起来有很多与 Flash Player 的错误相关的问题(swfupload known issue).适当的 Mac 支持和通过带有身份验证的代理上传是我不能没有的选项.这可能会排除所有基于 Flash 的选项:-( .
  • 我排除了所有 HTML/Javascript-only 选项,因为使用经典 HTML 控件一次只能选择一个文件.当您想选择文件夹中的多个文件时,点击 n 次浏览"按钮很痛苦.
  • Drag'n'Drop of files on the component would be a great plus.
  • It looks like there are a lot of issues related to bugs with the Flash Player (swfupload known issues). Proper Mac support and upload through proxies with authentication are options I can not do without. This would probably rule out all Flash-based options :-( .
  • I rule out all HTML/Javascript-only options because you can't select more than one file at a time with the classic HTML control. It's a pain to click n-times the "browse" button when you want to select multiple files in a folder.

推荐答案

OK 这是我的看法

我使用 swfupload 进行了一些测试,并且我之前有使用 Java 的经验,我的结论是无论使用什么技术,都没有完美的解决方案可以在浏览器上进行上传:您会上传大文件、通过代理、使用 ssl 等时总是会出现错误......

I did some testing with swfupload, and I have my previous experience with Java, and my conclusion is that whatever technology is used there is no perfect solution to do uploads on the browser : you'll always end up with bugs when uploading huge files, going through proxies, with ssl, etc...

但是:

  • Flash 上传器(即 swfupload)真的很轻量级,不需要用户授权,并且有一个非常酷的本机界面,我认为
  • java 上传器需要授权,但您可以对用户选择的文件做任何您想做的事情(如果需要,也称为压缩),并且拖放效果很好.不过,请准备好应对一些史诗般的错误调试.
  • 我没有改变使用 Silverlight,只要我愿意,也许这就是真正的答案,尽管这项技术还很年轻,所以......如果有机会,我会编辑这篇文章稍微摆弄一下 Silverlight

谢谢大家的回答!!

这篇关于从浏览器上传多个文件的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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