# P5js save() to input field?

**URL:** https://discourse.processing.org/t/p5js-save-to-input-field/11243
**Category:** Libraries
**Created:** [May 14, 2019, 10:15pm UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243 "2019-05-14T22:15:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Gollink](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@Gollink](https://discourse.processing.org/u/Gollink)
#### Post date: [May 14, 2019, 10:15pm UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/1 "2019-05-14T22:15:42Z")

</div>

I’m experimenting and learning about p5js for a new project I’m about to start. I got quite some processing experience but very little p5js experience. What I’m trying to do is make a SVG with p5.svg.js and trying to edit the library in such a way that I’m able to save the file to my server rather than downloading it to the webbrowser. I tried http posting the data uri to NodeJS but the problem is that I can’t turn the url into a file from there.

What would be a ideal way would be to have a hidden file input field on the page the p5js sketch is running in and have p5js input the file into the hidden field. This is off course a hacky way to do it but ideal because its all php from there on.

Would this be possible and what would be other(less hacky) ways to tackle this problem?

Edit: One way I found to do it is by putting the data uri in a text field. Other ideas are still appreciated.

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [May 15, 2019, 12:53am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/2 "2019-05-15T00:53:00Z")

</div>

creating files on server by JS is not wanted for security reasons,  
but how about save to google drive/dropbox/… or a SQLdatabase

---

<div class="post-metadata">

### Author: ![Gollink](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@Gollink](https://discourse.processing.org/u/Gollink)
#### Post date: [May 15, 2019, 5:58am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/3 "2019-05-15T05:58:16Z")

</div>

That would probably work yes. SQL would be great even. I’m trying to setup a webshop with algorithmically created products so SQL sounds like the way to go. But how 🙂

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [May 15, 2019, 6:04am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/4 "2019-05-15T06:04:39Z")

</div>

> [@Gollink](#):
>
> I’m able to save the file to my server rather than downloading it to the webbrowser. I tried http posting the data uri to NodeJS but the problem is that I can’t turn the url into a file from there.

Can you post what you have tried?

Did you setup your server already? Is your server serving the pages or are you working with a local environment?

When you are delivering a page from a server, you can use the server to safe the files.

Kf

---

<div class="post-metadata">

### Author: ![Gollink](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@Gollink](https://discourse.processing.org/u/Gollink)
#### Post date: [May 15, 2019, 6:16am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/5 "2019-05-15T06:16:32Z")

</div>

Not yet I’m setting up a Wordpress website right now, I tried doing a http post to a NodeJS server. Can post code if you’re interested.

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [May 15, 2019, 6:25am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/6 "2019-05-15T06:25:50Z")

</div>

Ok, so WP will be delivering the pages. Depending of what you want to store, you could use WP to store into the database. Or you can send the info to nodejs. In node, you should be able to save the file. You need to check your server provider to see what options it offers you for storage.

Kf

---

<div class="post-metadata">

### Author: ![Gollink](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@Gollink](https://discourse.processing.org/u/Gollink)
#### Post date: [May 15, 2019, 6:29am UTC](https://discourse.processing.org/t/p5js-save-to-input-field/11243/7 "2019-05-15T06:29:05Z")

</div>

My service provider uses MariaDB so I should be able to store the data uri in the database.
