Jump to content
  • Advertisement
Sign in to follow this  
J_Vitel

[web] How to select a Folder or Device in HTML

This topic is 4720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, here is the question, I have a page and I need to show the visitor a window where he can select a device or a folder located in his computer and retrieve the selected path, I tried with <input type="file"> but it only allows me to select files, I need to select folders or drives (C:\,A:\,D:\, etc;) Hope someone can help me

Share this post


Link to post
Share on other sites
Advertisement
You can do this in VBScript or javascript. Check out this page:

http://authors.aspalliance.com/brettb/VBScriptDrivesCollection.asp

There are a few other ways of accomplishing this as well. I believe you can use the ComDlg32.ocx, but it'll only work if the user of your page already has it. I believe that the Scripting object is standard on Windows systems...however, this likely won't work on Unix. Actually, the fact that you're selecting drives already implied that it won't be usable on *nix.

Edit:

However, there's not a simple way to upload the entire directory using this process. You could, perhaps, use scripting to dynamically create a hidden input field for each file in the path/drive selected, something like the following:

Drive "C:\Temp" contains 3 files:
1. characters.txt
2. story.txt
3. config.ini

Then on the scripting event when the user clicks "Submit", first dynamically create 3 hidden input elements with number-incremented names like "file1", "file2", "file3"... then have the code submit the form. You'd then need some server-side coding to search for parameters until one is not found (e.g. the code would find a value for form elements "file1", "file2", "file3", but not "file4", so it would stop searching). I hope this helps some...note the limitations of browsers and OS's though.

Share this post


Link to post
Share on other sites
Thanks for the replies, I didn't mention the fact that I don't want to upload the entire directory, just want the user to select a path, wich I'll use to scan for viruses, so all I need is a directory dialog and a path, a string like "C:\My documents" as return.

Thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
?

... you're making a virus-scanning web page?

Share this post


Link to post
Share on other sites
No, it's just an interface for a security suite wich contains an antivirus, the configuration interface is made on webpages (using something like jsp) so, the antivirus executes locally, I just need to get the user's input, in this case the folder's path to be scanned and store it into a config file wich the antivirus will read.

I was thinking maybe a java applet could display a Directory Dialog, but I don't know if that's posible or how to do it.

Share this post


Link to post
Share on other sites
Quote:
Original post by J_Vitel
No, it's just an interface for a security suite wich contains an antivirus, the configuration interface is made on webpages (using something like jsp) so, the antivirus executes locally, I just need to get the user's input, in this case the folder's path to be scanned and store it into a config file wich the antivirus will read.

I was thinking maybe a java applet could display a Directory Dialog, but I don't know if that's posible or how to do it.


I'm still confused. That would take a whopping five minutes to accomplish in .NET. To do it via a web page (HTA, I'm assuming?), you would have to use VBScript or JScript as Mattman described.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!