Best way to upload multiple files from a browser

筅森魡賤 提交于 2019-11-28 16:05:47

I implemented something very recently in Silverlight.

Basically uses HttpWebRequest to send a chunk of data to a GenericHandler.

On the first post, 4KB of data is sent. On the 2nd chunk, I send another 4K chunk.

When the 2nd chunk is received, I calculate the round trip it took between first and 2nd chunk and so now the 3rd chunk when sent will know to increase speed.

Using this method I can upload files of ANY size and I can resume.

Each post I send along this info:

[PARAMETERS] [FILEDATA]

Here, parameters contain the following: [Chunk #] [Filename] [Session ID]

After each chunk is received, I send a response back to my Silverlight saying how fast it took so that it can now send a larger chunk.

Hard to put my explaination without code but that's basically how I did it.

At some point I will put together a quick writeup on how I did this.

I've never used it with files of 2GB in size, but the YUI File Uploader worked pretty well on a previous project. You may also be interested in this jQuery Plugin.

That said, I still think the Java Applet is the way to go. I think you'll end up with less portability and UI issues than you expect and Drag/Drop works great. For the record, Box.net uses a Java Applet for their multi-file quick uploads.

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

There are a number of free flash components that exist with nice multiple file upload capability. They make use of ActionScripts FileReference class with a PHP (or whatever) receiver on the server side. Some have recently broken with the launch of FP10 but I know for certain that swfupload will work :)

Hope this helps!

What about these two Jupload http://jupload.sourceforge.net/ and jumploader http://jumploader.com/

Both are java applets but they are also both really easy to use and implement.

what about google gears?

There are HTTP/HTTPS upload controls that allow multi-file upload. Here is one from Telerik, which I have found to be solid and reliable. The latest version looks to have most if not all of your feature requirements.

You can upload multiple files with HTTP forms as well, as Dave already pointed out, but if you're set on using something beyond what HTTP and Javascript offers I would heavily consider Flash. There are even some pre-existing solutions for it such as MultiPowUpload and it offers many of the features you're looking for. It's also easier to obtain progress information using a Flash client than with AJAX calls from Javascript since you have a little more flexibility.

You may check the Apache Commons FileUpload package. It allows you to upload multiple files, monitor the progress of the upload, and more. You can find more information here:

http://commons.apache.org/fileupload/
http://commons.apache.org/fileupload/using.html

Good luck

Easiest way of file upload in java is GOJFileUpload.jar library

Here is the gojfileupload library tutorial:

GOJFileUpload

They give two method

  • UploadFile(String filepath,ArrayList imagenames,HttpRequest request)
  • UploadFile(String filepath,ArrayList dataname,ArrayList imagenames,HttpRequest request)

They'll return you HashMap the all file name which you uploaded after uploading at your given destination folder.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!