Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading