# P5.js tables saveTable

**URL:** <https://discourse.processing.org/t/p5-js-tables-savetable/18341>\
**Category:** Coding Questions\
**Created:** [March 3, 2020, 9:20am UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341 "2020-03-03T09:20:36Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 9:20am UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/1 "2020-03-03T09:20:36Z")

</div>

I’m trying to save my highscore when my player dies but instead of saving it to the file it got the info from. It creates a new file and send it download. Why is it doing that? & how can I get it to save the file to the high score file I made to store the scores.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 1:15pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/2 "2020-03-03T13:15:06Z")

</div>

> [@Creating and Populating a Table From Scratch](https://discourse.processing.org/t/creating-and-populating-a-table-from-scratch/12658/3):
>
> I’ve made a sketch that stores and reads an array of CSV row strings from the browser’s local storage using storeItem() & getItem() respectively; then converts that array to p5.TableRow objects; and finally use p5.Table::addRow() to populate a p5.Table container: card_index_dividers[http://p5js.org/reference/#/p5/getItem](http://p5js.org/reference/#/p5/getItem)[http://p5js.org/reference/#/p5.Table/addRow](http://p5js.org/reference/#/p5.Table/addRow) Each mouse click adds a new p5.TableRow to the p5.Table container, updating the browser’s local storage as well. …

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 1:29pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/3 "2020-03-03T13:29:21Z")

</div>

That doesn’t explain why it downloads the file instead of saves the file to where the file is.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 1:31pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/4 "2020-03-03T13:31:56Z")

</div>

Browsers don’t give us any permission to change anything on a user’s computer! 👾

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 1:35pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/5 "2020-03-03T13:35:25Z")

</div>

so basically you saying it will only download the file unlike processing where it saves the scores to the file where it first got the scores

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 1:49pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/6 "2020-03-03T13:49:07Z")

</div>

Correct! Browser client-side code is run inside a very restricted sandbox w/ lotsa restrictions on what it can do to a device. 🤖

If you have more storing requirements than a **storeItem()** can offer: 📁  
[p5js.org/reference/#/p5/storeItem](http://p5js.org/reference/#/p5/storeItem)

You’re gonna need to contact a server-side code which can save your files remotely. 💡

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 2:13pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/7 "2020-03-03T14:13:14Z")

</div>

I’m not trying to do anything that effects anything outside of my program

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 2:29pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/8 "2020-03-03T14:29:24Z")

</div>

It’d be really nice if we could at least save files into the same folder our client-side app is running. 🏃‍♂️

However, even restricting our file saving to the app’s folder isn’t allowed! 😢

For all available “workaround” alternatives for storing, you can read this article below: 👓

> **[Client-side storage](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage)**
>
> That's it for now. We hope you've found our rundown of client-side storage technologies useful.

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 2:42pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/9 "2020-03-03T14:42:04Z")

</div>

Well js is dumb now I should return to java the smarter language

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 2:52pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/10 "2020-03-03T14:52:35Z")

</div>

> [@ctrembla](#):
>
> Well JS is dumb now…

It’s not JS’ fault. Any other browser client-side language would have those same restrictions! 🙄

BtW, JS has a server-side version called Node.js which can save to disk: 🤩

> **[Node.js](https://nodejs.org/en)**
>
> Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 3:05pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/11 "2020-03-03T15:05:34Z")

</div>

if every language would have same trouble why did java do what I’m trying to do without problem?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 3:13pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/12 "2020-03-03T15:13:18Z")

</div>

When Java used to run online as a browser plugin it had similar restrictions as well. 🤡

Any client-side apps targeting browsers, regardless the language they have been written in, will have those same storage restrictions! 😬

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 3:14pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/13 "2020-03-03T15:14:14Z")

</div>

well i’m going back to a language smart enough to alter its own files

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 3:21pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/14 "2020-03-03T15:21:06Z")

</div>

Well, as I have already informed, you can also use JavaScript to alter local files.

But you’re gonna need to use its Node.js version, which is a server-side JS.

In general, any programming language can have free reign over its local file system as long as it’s running outside a sandbox.

A browser is a kind of sandbox btW:

> **[Sandbox (computer security)](https://en.wikipedia.org/wiki/Sandbox_(computer_security))**
>
> In computer security, a sandbox is a security mechanism for separating running programs, usually in an effort to mitigate system failures or software vulnerabilities from spreading. It is often used to execute untested or untrusted programs or code, possibly from unverified or untrusted third parties, suppliers, users or websites, without risking harm to the host machine or operating system. A sandbox typically provides a tightly controlled set of resources for guest programs to run in, such In...

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 3:36pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/15 "2020-03-03T15:36:41Z")

</div>

Wouldn’t that file in the program be local so when I try saving the table shouldn’t it have saved to that file?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 3, 2020, 3:58pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/16 "2020-03-03T15:58:44Z")

</div>

Browsers allow us to load files located in the same folder (and its subfolders) as the current app.

But when we save a file, even when using the same name as an existing 1, we can place any type of content in it; even content which doesn’t match the file’s extension mime!

That’s why browsers don’t allow us to save files. Instead a browser pops up a save dialog window to the user, so the user has full control whether to allow the save or not.

Besides cookies and local storage, the only full-fledged option is sending a file to some server, so it’s saved there instead of the user’s local file system.

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [March 3, 2020, 6:14pm UTC](https://discourse.processing.org/t/p5-js-tables-savetable/18341/17 "2020-03-03T18:14:47Z")

</div>

The smart thing for them to do is have everyone use a copy and whenever it saves it saves to the origanal
