skip to Main Content

Is there a way in Javascript that we can get a folder in the root folder to a variable then use .getFiles() to get the files in that folder?

I worked with scripting in Photoshop with Javascript and these codes works:

Destination = Folder ('G:/My Projects/Project 2/Sounds');
Files = Destination.getFiles();

But in web developing it does not work. Is there a way? Thank you.

Is there a way that I can use paths like (‘/Sounds’) ?

2

Answers


  1. The browser doesn’t allow you to access the file system due to security reasons.

    What if any page you visit could do this?

    // over simplified example
    var passwords = File('C:/passwords.txt'); 
    
    Login or Signup to reply.
  2. No. For your web browser, the root of the folder starts at html page you are serving. Only those directories and sub-directories which lie within the same folder as the html page can be accessed. To achieve what you desire, you probably need to write a server too.

    yeah. if you have following directory structure

    /(root1)
    |--file1
    /(root)
     |--index.html
     |--dir1/
     |--dir2/
     --dir3/
       |--file
    

    Only dir1,dir2 and dir3 contents can be accessed. file1 can’t be accessed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search