# Upload random Shape

**URL:** <https://discourse.processing.org/t/upload-random-shape/2751>\
**Category:** Coding Questions\
**Created:** [August 18, 2018, 1:33pm UTC](https://discourse.processing.org/t/upload-random-shape/2751 "2018-08-18T13:33:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vale](https://avatars.discourse-cdn.com/v4/letter/v/9de053/32.png) [@vale](https://discourse.processing.org/u/vale)\
**Post date:** [August 18, 2018, 1:33pm UTC](https://discourse.processing.org/t/upload-random-shape/2751/1 "2018-08-18T13:33:38Z")

</div>

Hi everyone, I am trying to upload randomly svg files with this method:  
The pictures are picked to form 3 different groups  
it should be displayed 3 images at time.  
[i did an example to be sure]

 ![46](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a2d4a5d59e03ab8945bf240641de264656537b39.png)

That’s what I have done (just to pick one shape) but sometimes it gives me this error:  
(even if in the folder all the file are named right)

 ![Screen%20Shot](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0f55d531d27acbd61dd159ebb2fd6fcacdcb968e.png)

```auto
void setup() {
  size(800, 500);
  
  PShape fragment;
float a = random(1,6);
int fragNumber = int (a);
  fragment = loadShape("frag" + fragNumber + ".svg");
  shapeMode(CENTER);
  shape(fragment, width/2, height/2, 100, 100);
  smooth();
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [August 18, 2018, 4:37pm UTC](https://discourse.processing.org/t/upload-random-shape/2751/2 "2018-08-18T16:37:54Z")

</div>

Please, can you format your code above?  
To do that, edit your post, select your code and click on the `</>` icon on top of the edition frame.

Also, can you create a [github](https://github.com/) repository with a working example with your data folder and some pictures in it?

You also say that you are getting an error. Can you precise wich one?

If you do that people will be more willing to help you 🙂

---

<div class="post-metadata">

**Author:** ![TheWizardBear](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/thewizardbear/32/3552_2.png) [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)\
**Post date:** [August 19, 2018, 9:18am UTC](https://discourse.processing.org/t/upload-random-shape/2751/3 "2018-08-19T09:18:22Z")

</div>

What the error message is saying is that it can’t find a file called “frag2.svg” to read, which means that it probably isn’t in the folder. In your sketch folder, have you got files called:

- frag1.svg
- frag2.svg
- frag3.svg
- frag4.svg
- frag5.svg

as if any of them are missing, then then you will get errors thrown at you.

Also (though you might already be aware of this), the int() function always rounds down so the second number in your random function should be 1 more than the biggest number in your files (e.g if there are 6 files you want this number to be 7).

> [@vale](#):
>
> ```auto
> float a = random(1,6/*this number*/); 
> int fragNumber = int (a);
> 
> ```
