If you've used Flickr, you may well have seen their funky uploading tool that lets you pick multiple files to upload and then shows you the status of each as it uploads.
It's very cool, and you may want to copy it on your site. So, how would you do it?
Well, you can't. At least not with the standard tools of the web - HTML and JavaScript. It's a limitation of the input type="file" HTML control that it only allows you to pick a single file. JavaScript can't help because JavaScript code cannot have access to your file-system. So with any standard web-server language (Java, ASP, ASPX, PHP, etc), the user will always have to pick their files one at a time (even if you can spruce things up slightly by capturing all of the files in a single list once they've been chosen).
Well ... actually you can, but you have to rely on something happening at the user's end.
- You can force the user to zip up all of the files and upload a single archive (which you can then manipulate and unzip using the standard library functionality of your chosen language).
- You can use a Java Applet, since Java can access files on your machine if you allow it to. This means that the user will have to install the Java runtimes if they don't have them already. You may also need to look into security-signing your applet.
- You can use an ActiveX control. This has the severe limitation that it will only work on Windows systems. Also, you'll probably need to security-sign it to stop dire warnings from appearing when users visit your site, and it probably won't work in Firefox.
- You could use a client application. This gives you lots of control, but breaks the web paradigm slightly and you'll have to think about which platforms you want to code for and support.
- Ah, so how do Flickr do it? They use Flash. It's very nifty, and you might not even notice that it's a Flash application. Uploading multiple files was added in Flash 8 and seems to work well.
Update: 2nd April 2008. We started to look at how this is possible using Flex, and it looks doable using the free version of the tool (if a little painful).
Oh, and we looked at how YouTube does it - they use Java. Interesting.
Meanwhile, Microsoft are pushing Silverlight harder and harder. You can't view some of their webcasts without installing it, and every time you download something you are told you'll get a better experience with it. Perhaps it will reach the tipping point after all?