views:

614

answers:

6

I need an easy way to allow users to upload multiple files at once (ie I need to allow a user to upload a folder). I do not wish to put the burden of zipping on the user.

I would prefer to avoid Flash or variants if possible. I'm looking for a straight javascript / HTML solution if it is possible. Please note, this rules out the answers at: http://stackoverflow.com/questions/159600/multiple-file-upload.

+3  A: 

If you're avoiding Flash (and presumably Java?) the JS/HTML-only solution still requires single-file inputs, but essentially you attach an onchange event to your input, adding a new input to the DOM whenever a file is selected.

eyelidlessness
Is it possible to get a list of files within a particular folder, and feed that automagically into the input control?
torial
I answered by own question from the comments: http://www.codeproject.com/KB/scripting/search_in_files.aspx
torial
Although, the problem w/ the link I found is that it requires ActiveX. And at that point, I might as well use flash :-/
torial
+1  A: 

This is impossible with pure js/html. The best you can do is put file upload controls on the page and force the user to select each one individually.

EndangeredMassa
It's not *impossible* it just requires selecting each file individually.
eyelidlessness
How is it impossible?
torial
By design, the file object cannot be manipulated in that way. None of the browser implementations allow it. Why? Because there are all kinds of nasty things you couldo if it were possible.
wcm
I take "at once" mean with a single "select file" dialogue. The second line of my post covers your concern about being *technically* possible.
EndangeredMassa
+1  A: 

This isn't a pure js/html solution. As EndangeredMassa has pointed out, it's not possible. In fact, this idea is an IE/Windows only solution. I don't recommend it, but it can work.

So, all disclaimers aside ...

Many years and several employers ago, we used to do some client side stuff that instantiated the FileSystemObject. It would iterate through each of the files and pass them through to the server one at a time. Can't remember the details of how we did that :o(

Anyway, this usually meant that the client box would need to have to add the site to the list of trusted sites and give trusted sites a bunch of permissions that are turned off (for very good reasons). Stuff like the ability to Initialize and script ActiveX controls not marked as safe. That kind of thing.

I know that this isn't a perfect answer, but it could point you in the right direction.

wcm
+2  A: 

FTP? And if necs, wrap in Java Applet, ActiveX or whatever you want.

If not, although you don't want flash, SWFUpload is quite cool, you may want to reconsider it as a decent option.

scunliffe
+1  A: 

You won't be able to do it with just HTML and Javascript. I'd recommend trying Fancy Upload, a MooTools plugin for multiple file uploads. It uses a mixture of JavaScript and Flash, but degrades gracefully. It works with all major browsers including IE6 and there is also a Flash 10 compatible release available for download (though the demo hasn't been updated yet).

VirtuosiMedia
+1  A: 

Here is pure JS solution using ExtJS library

Thevs