5

If i want to take a file as a input in HTML i will be using

<input type="file">

Now my question is, is it possible to take a whole directory as a input,if yes how to do that?

Hariharbalaji
  • 2,498
  • 8
  • 36
  • 51
  • What would be the point of passing a folder name to the server? After all, it has no access to the client (your machine). If instead you wanted to upload a whole folder of files at once, any of the multi-upload systems suggested below would suffice. – K Prime Dec 03 '09 at 06:24

5 Answers5

6

Not explicitly through HTML (although I'm not sure about HTML 5). You need some Java applet or Flash movie to do it. One way I do it is by using a custom PHP script that takes in a zip or tar file and decompresses it on the back end then dumps it.

gonzofish
  • 1,417
  • 12
  • 19
  • 1
    This answer mentiones actual Flas-based implementation: [swfuploader](http://stackoverflow.com/questions/2176184/input-field-for-browsing-folder), but their link is dead. This [other link to swfuploader](http://code.google.com/p/swfupload/) seems better. – G. Stoynev Oct 09 '12 at 02:42
5

Short answer: No, it's not possible.

You'll need to use something like a Java applet, ActiveX plugin or Flash (I know it does at least multiple files, not quite sure about folders) to do that.

deceze
  • 510,633
  • 85
  • 743
  • 889
3

AFAIK this is not possible. You can only browse for files. As others have mentioned go for a flash plugin or an applet.

rahul
  • 184,426
  • 49
  • 232
  • 263
2

There was a post in another site

it says zipped folder or tar will be taken in as input for <input type=FILE /> it also says some thing about javascript which can come in handy for uploading folder..

the best option would be writing in Java applet, ActiveX plugin or Flash or may be even something called Jupload(but this takes only mutiple file uploads..not sure about folder though)

This is the link to that post See This Link

Hope this helps..

Richie
  • 9,006
  • 5
  • 25
  • 38
0

Is it ok to use

<input type="file" webkitdirectory mozdirectory id="folder"/>
Nikita
  • 27
  • 1
  • 5
  • But it is working for that folder which contains only small number of files, not working for large no of files. how to resolve this? – Nikita Jul 08 '22 at 05:06