View Full Version : Use Javascript to list local dir contents

05-25-2005, 07:18 PM
Well here is my problem in general
I would like to allow a user to select multiple files and upload them at one time. It looks like the built in file upload for html will only allow 1 file to be selected at a time.

To get around this, I thought that if I had a user select 1 file, then use a little JS to take the file path to list the directory contents to a checked list box or something. Here the user could select the filenames and then upload them all at one time.

My problem is that I am unable to figure out how to access / list the contents of a local directory for a user. (or my problem is I am taking the wrong approach here)

If anyone knows how to go about this / has a better idea / knows how to allow multi selections when uploading files / know of some good sites or references please let me know. My luck with google seems to be running out



Eternity Angel
05-25-2005, 07:36 PM
#1 - you can't use JS to access the user's local harddrive.

#2 -
<form enctype="multipart/form-data" action="..." method="post">
Upload Files<br><br>
1. <input name="file1" type="file"><br>
2. <input name="file2" type="file"><br>
3. <input name="file3" type="file"><br>
4. <input name="file4" type="file"><br>
5. <input name="file5" type="file"><br>
6. <input name="file6" type="file"><br>
7. <input name="file7" type="file"><br>
8. <input name="file8" type="file"><br>
<input type="submit" value="Upload">

05-25-2005, 08:30 PM
Thanks for the tip about JS, it explains why nothing was forth coming.

Also thank you for the code, its close to what I am looking for, I just left out an important detail. I am trying to build something where a user could hit the browse button and then select a bunch of files at once (like holding down the shift button). If the user could select the files and it returned a string or an array, I could split them into single entries for upload much like the 8 line example you posted.

The built in file select box for html doesnt support this, but are there any other file explorer like things that i could have popup allowing users to select different files?

Thanks again!