currently I’m working on an interactive slideshow in p5 which I previously built up in processing. It all works so far but I have some issues on making an easy way to load all the images. I have to say that I have around 50 Images/clips, with mixed named and mixed formats (jpeg, png, mov, gif) but they are all stored in an ‘image’ folder in my p5 sketch (web editor).
in my older processing sketch i just listed all the files as a file directory and load them automatically
File dir = new File(dataPath("images/"));
so thats not working in p5. now my question is:
how do i get access to the content of a folder as a whole? like to store the filenames in an array so that i can loop though the names to load them.
Have you uploaded these files to the web editor? Online javascript cannot access folders of files on your personal computer without a dialog – for security reasons. Otherwise every webpage that ran a script in your browser could browse your desktop for private stuff.
I believe (?) that JavaScript is a client-side language – it cannot search directories on the server for you, you would need to use AJAX for that.
If you have to upload these images anyway, one easy thing would be to upload a list of image file names as a separate txt file. Then you could load the image file list and loop over it. If you want to change the list, edit the text file – you don’t need to delete and re-upload images every time.