Image Array from non-sequential image names

Welcome to the forums!

Unfortunately, you have to know the names of the files ur gonna use, before hand. Whether you’re serving your p5 code in a <script> header, or separately as a .js file, when your page gets served to the client, it has no ‘concept’ of where it came from (compared to, say, a Python script that ‘knows’ where it resides, BECAUSE its being run on the local maching)

You might be testing your p5 in localhost, but, for very good security reasons, an html page is more like a set of instructions telling the browser what to load.

Long story short…if you don’t know your image names before-hand, the HTML page can’t bring them over to the browser.

(This IS possible in Java however, one of the few differences between P5 and Java Processing)

3 Likes