# Image Array from non-sequential image names

**URL:** https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990
**Category:** Coding Questions
**Created:** [May 17, 2020, 11:35pm UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990 "2020-05-17T23:35:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![clintsleeper](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@clintsleeper](https://discourse.processing.org/u/clintsleeper)
#### Post date: [May 17, 2020, 11:35pm UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990/1 "2020-05-17T23:35:44Z")

</div>

Hi all,  
I’m hoping I have a simple question - I’m trying to populate an image array from a folder where images are stored but will not have sequential naming schemes (the folder is populated by a PHP uploader with a handful of _different_ problems).

I’ve been checking around with no luck - is there a simple way to have P5 populate an array with all of the image files so I may begin to work with them?

(Sample code with what I think I’m trying to do - this code does nothing.)

```auto
let allimages = [];
let names;

function setup() {
  createCanvas(windowWidth,windowHeight);
  for (let i = 0; i<10; i++){
allimages[i] = loadImage('folderURL/${names}.jpg');
}}

function draw() {
  background(220);
  image(allimages[0],0,0);

}

```

Thanks so much for any assistance or clever workarounds!

---

<div class="post-metadata">

### Author: ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)
#### Post date: [May 18, 2020, 1:24am UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990/2 "2020-05-18T01:24:22Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)
#### Post date: [May 18, 2020, 2:45am UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990/3 "2020-05-18T02:45:27Z")

</div>

> [@clintsleeper](#):
>
> (the folder is populated by a PHP uploader with a handful of _different_ problems).

As @tony points out you need to know filenames. I suppose your PHP uploader knows those names and could write them to a file. File with a known name that can be used and accessed in p5 code.

---

<div class="post-metadata">

### Author: ![clintsleeper](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@clintsleeper](https://discourse.processing.org/u/clintsleeper)
#### Post date: [May 23, 2020, 6:54pm UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990/4 "2020-05-23T18:54:48Z")

</div>

Thanks! That’s exactly what I ended up working on - I appreciate it!

---

<div class="post-metadata">

### Author: ![clintsleeper](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@clintsleeper](https://discourse.processing.org/u/clintsleeper)
#### Post date: [May 23, 2020, 6:55pm UTC](https://discourse.processing.org/t/image-array-from-non-sequential-image-names/20990/5 "2020-05-23T18:55:54Z")

</div>

You saved me hours of bumbling around! Thank you!
