How to access files in the same folder (and deeper) as my .html and .js file? via /r/learnprogramming

How to access files in the same folder (and deeper) as my .html and .js file?

I have a HTML+Javascript website running on my computer. Nothing fancy, not even CSS. Also, it's not running as localhost but just file:///C:/…../test.html.

This HTML and javascript file is in a folder X. This folder X has a bunch of subfolders a, b, c, d, e, f that all have subfolders, and these subfolders have subfolders as well and so on. All levels of these subfolders contain lots of images each with inconsistent file names. I want to be able to access all these images from the website. Or said in another way, I want to, without hardcoding the relative paths anywhere, be able to access – from the website – all these thousands of images that are in the same folder as the HTML and javascript file, and all relative subfolders.

How do I do that?

I've read many times that "javascript cannot access the file system!" which I understand in the context that you have a server somewhere that sends out javascript to clients that are somewhere else. But I am running all the files myself on my own computer! All the images are right there next to the actual HTML and javascript file that I'm running. I mean, in the HTML file, I can set an image src to be a relative "/g4/b/sh/026a.png" and that's fine. Then why can't I just somehow get ALL these files?

Submitted July 11, 2017 at 01:06PM by RaigekiAKH
via reddit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s