Forum Moderators: open

Message Too Old, No Replies

Read Local Directory Javascript

Need to read local directory contents and pass to file forms

         

hughie

3:33 pm on May 28, 2007 (gmt 0)

10+ Year Member



Hi All

Very simply - Is it possible to read the contents of a local directory using javascript?

I need to to automatically fill in a load of file fields for quicker uploading of multiple files.

eg. user searches for file, selects it, then hits a button and all other files in that folder are parsed and populate the other file inputs.

Hope that makes sense,
Hughie

hughie

8:57 pm on May 28, 2007 (gmt 0)

10+ Year Member



Looking into this it's probably not possible without a java applet as it's unsecure. anyone got any experience of this issue?

Dabrowski

5:33 pm on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're right, no access with JS for security. However my mum found a site that listed some files on her drive. They were photo's so the names couldn't be guessed by some ad company. Don't know how they did it, I'll see if I can get the site name off her.

hughie

3:32 pm on May 30, 2007 (gmt 0)

10+ Year Member



It looks like there are some crazy objects that only I.E. can use which is no good to me. I've given up and gone for multiple file browser inputs.

Dabrowski

3:46 pm on May 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could add a thing so whenever one is used another one appears below it?

mehh

12:09 pm on May 31, 2007 (gmt 0)

10+ Year Member



you cant read their directory but you may be able to minipulate the file they select eg:

user inputs C:/Documents and Stetings/blah/blah/blah.doc
and you change that in the next box to be:
C:/Documents and Stetings/blah/blah/blah_number2.doc

Would that be useful?

rocknbil

7:40 am on Jun 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't populate a file upload field for the same reason. :-)

What I do with these is set in another page prior to the upload with an option list. "Select how many images you plan to upload." As one who tries to eliminate as many clicks and pages as possible, I feel like it's a compromise but necessary.

I suppose you could do the same thing on a single page with Javascript by using document.write() to a div, but then it becomes Javascript-dependent.

hughie

12:28 pm on Jun 1, 2007 (gmt 0)

10+ Year Member



It's not the multiple inputs that's the issue, the issue is the annoying task of having to select every file to upload from those multiple inputs.

In some cases i needed to upload 100 images with the same database attributes, but different filename, so it was just a boring job that could be made a lot simpler with a "select all" function.

StupidScript

5:39 pm on Jun 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are running the form page from your own, local script (i.e. using the file:/// protocol) you can do pretty much anything you like.

If this is to be hosted and use the http:// or similar protocol, then you need the user's permission to elevate the privileges of the script so it can access local directories.

See Mozilla's Javascript Signed Scripts [mozilla.org] for more.