1

I have a simple app which is supposed to show all images in a specific folder. As far as I understand, javascript is not allowed to load local files. Is this correct? Is it possible to load all images file paths from the public/images folder into an array?

Thanks..

Tobias Moe Thorstensen
  • 8,861
  • 16
  • 75
  • 143

1 Answers1

0

it is not possible because JavaScript runs on the browser, but the files tipically are hosted on a server. Your server needs to expose an API or any kind of information about the files that are contained in a specific folder, then you can fetch every file using Ajax.

Michele Riva
  • 552
  • 9
  • 24
  • 1
    Sorry if I was unclear but the Application is supposed to load images from the server side. This posted helped me alot: https://github.com/gatsbyjs/gatsby/issues/3663 I'm loading Resources from the Public/images folder in my web-app. – Tobias Moe Thorstensen Dec 07 '18 at 07:26