Home > Back-end >  Accessing a folder outside the current folder for a file path in JS
Accessing a folder outside the current folder for a file path in JS

Time:12-17

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!

CodePudding user response:

./ -> 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.

CodePudding user response:

I'm not sure what exactly you're asking here, but these paths might be just URLs (as inside HTML), in which case you could get from inside a current location root/L2 to the desired location by using ../inventoryAssets. The .. gets out/up from the current L2 (then at root/), from where then to go into inventoryAssets.

  • Related