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

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

问题描述

我正在开发一个Web应用程序。有一个地方,用户可以用HTTP协议上传文件。经典的HTML文件上传控制和Java applet之间有一个上传文件的选择。

传统的HTML文件上传并不好,因为一次只能选择一个文件,在实际上传过程中很难获得任何进度指示最后使用计时器刷新进度指示器,通过AJAX调用从服务器获取数据)。使用Java applet,我可以做更多的事情:一次选择多个文件(即使是一个文件夹),压缩文件,得到一个真正的进度条,拖动applet上的文件,等等...

但是有一些缺点:$ b​​
$ ul

  • 使它在Mac Safari和Mac Firefox上正常工作是一场噩梦(Thanks Liveconnect)

  • UI并不完全是原生UI,有些人注意到
  • >
  • 这个applet并没有像应该那样快速响应(可能是我的错,但是一切看起来都对我有好处)

  • Java <$> c $ c> UrlConnection 类与HTTPS,所以我使用Apache常见的HTTP客户端来做实际的HTTP上传。这是一个非常大的软件包,会减慢.jar文件的下载速度。
  • Apache常见的HTTP客户端有时会遇到麻烦。

  • Java运行时相当大


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



    问题

    如果您有以下要求: b
    $ b


    • 通过HTTP或HTTPS轻松上传多个文件

    • 压缩文件以减少上传时间
    • li>
    • 上传应该可以在任何平台上运行,使用本地用户界面

    • 必须能够上传大文件,至少2GB b
    • 您对技术有全面的了解



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




    编辑:


    • 这个组件上的文件是一个很好的补充。
    • 看起来好像有很多与Flash Player相关的错误( swfupload已知问题)。正确的Mac支持和通过代理上传身份验证是我不能没有的选项。这可能会排除所有基于Flash的选项:-(。

    • 我排除所有HTML / Javascript-only选项,因为您不能一次选择多个文件经典的HTML控制,当你想在一个文件夹中选择多个文件时,点击n次浏览按钮是一件很痛苦的事情。
    • >解决方案
  • 确定这是我的承诺



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



    但:




    • Flash uploader(la swfupload)实际上是轻量级的,不需要用户的授权,并且具有非常酷的本地接口,我认为
    • 一个java上传呃需要授权,但是你可以用用户选择的文件做任何你想要的(也可以压缩,如果需要的话),并且拖放效果很好。尽管如此,为了一些史诗般的bug而做好了准备。

    • 只要我希望这也是真正的答案,相当年轻,所以...我会编辑这个帖子,如果我有机会摆弄Silverlight



    感谢所有答案!!


    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.

    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.

    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:

    • 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

    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.

    Question

    If you had the following requirements:

    • upload multiple files easily from a browser, through HTTP or HTTPS
    • compress the files to reduce the upload time
    • upload should work on any platform, with native UI
    • must be able to upload huge files, up to 2gb at least
    • you have carte blanche on the technology

    What technology/compontent would you use?


    Edit :

    • 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 this is my take on this

    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...

    BUT :

    • a flash uploader (a la swfupload) is really lightweight, doesn't need authorization from the user and has a native interface which is REALLY cool, me thinks
    • a java uploader needs authorization but you can do whatever you want with the files selected by the user (aka compression if needed), and drag and drop works well. Be prepared for some epic bugs debuggin' though.
    • I didn't get a change to play with Silverlight as long as I'd like maybe that's the real answer, though the technology is still quite young so ... I'll edit this post if I get a chance to fiddle a bit with Silverlight

    Thanks for all the answers !!

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

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