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.
That doesn’t explain why it downloads the file instead of saves the file to where the file is.
Browsers don’t give us any permission to change anything on a user’s computer!
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
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:
You’re gonna need to contact a server-side code which can save your files remotely.
I’m not trying to do anything that effects anything outside of my program
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:
Well js is dumb now I should return to java the smarter language
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:
if every language would have same trouble why did java do what I’m trying to do without problem?
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!
well i’m going back to a language smart enough to alter its own 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:
Wouldn’t that file in the program be local so when I try saving the table shouldn’t it have saved to that file?
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.
The smart thing for them to do is have everyone use a copy and whenever it saves it saves to the origanal