Choosing a directory on an HTML page

How to create a directory on an html page. If I use the input file element, I can only select the file, but I need to select the directory. I need to do this because the user must choose the right path inside his computer.
Any solutions?

+42
html directory
May 11 '10 at
source share
5 answers

Cannot execute pure HTML / JavaScript for security reasons.

Choosing a file to download is the best you can do, and even then you won’t get its full source path in modern browsers.

You can compose something together using Java or Flash (for example, using SWFUpload as the basis), but it works a lot and brings additional compatibility issues.

Another thought would be to open an iframe showing the user's C: drive (or something else), but even if it is possible these days (it may be locked for security reasons, have not tried for a long time), it will not be possible for your website for linking with iframe (again for security reasons).

Why do you need this?

+21
May 11 '10 at 10:07
source share

Try it, I think this will work for you:

 <input type="file" webkitdirectory directory multiple/> 

You can find a demonstration of this at https://plus.google.com/+AddyOsmani/posts/Dk5UhZ6zfF3 , and if you need more information, you can find it here .

+45
Sep 24 '14 at 14:10
source share

Scenarios are inevitable.

This is not provided due to a security risk. <input type='file' /> closest, but not what you are looking for.

Checkout this example , which uses Javascript to achieve what you want.

If the OS is windows, you can use VB scripts to access the main management files to find the folder.

+2
May 11 '10 at 10:26
source share

If you are a server and a user (for example, you create an application that works through a browser and you need to select a folder), try calling JFileChooser from the server when a button is pressed in the browser

 JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle("select folder"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); 

This code is disconnected from here.

+1
Feb 09 '16 at 13:13
source share

I did the job. I had a hidden text box for storing the value. Then, in form, I copied the path value, for a smaller file name to a hidden folder. Then set the fileInput field to "". Therefore, the file does not load. I do not remember the events of the fileUpload control. Maybe an exchange. That was the time. If there is a value, I parsed the file name and returned the folder to the field. Of course, you must confirm that the file is a valid file. This will give you a client workstation folder.
However, if you want to display server paths, this requires a completely different coding approach.

0
May 12 '17 at 19:51
source share



All Articles