javascripthtmlfile-structure

Accessing a folder outside the current folder for a file path in JS


I am a new JS programmer and am working on a game in HTML/JS. There is an inventory, and I need to have access to all the possible item assets in the root/inventoryAssets folder. I am wondering how to access this folder from inside of another folder root/L2 to get the images.

I have looked for a while and haven't found any examples in pure js, and was wondering if there are any ways to do it. Does anyone know how to do this? Thanks!


Solution

  • ./ -> current folder

    ../ -> up one folder

    ../../ -> up two folders

    ../root/L2 -> up one folder following root and L2 folders

    ./image.jpg -> access image inside the current folder.

    ../image.jpg -> access image one up the current folder.