Feature request: outputting data to computer

It would be great to have a way to save files onto the computer, maybe as .txt files, or to download an image, via code. I know it's possible to do it by right clicking a variable and exporting/importing it, but it would be very useful to do it with code.

Uses

It would make it possible to make a program which, for example, gets information from a website and exports it to a .txt file.
Another use could be for a website creator; in snap! you could make the code so that you can design a website from the canvas, and then it outputs it as a .txt or .html file.
Or maybe it could just be used to save and access data.

There may be a way to program it using JavaScript, but I don't know how to do that, and it would be much easier to have a block for that.
Is it possible to do that?
Does anyone know (if there is) the JavaScript to do that?

Thanks!!
:slightly_smiling_face:

We'd love to be able to do that, but it's a deliberate restriction in Javascript. They're worried about someone making a malicious web site that messes up your computer. So the only way to access the local disk is to open a system file dialog, in which the user has to click OK before it happens.

Hi @biran4454,

As Brian said, browser restrictions (and I think this restriction is good) make that you must fire a system file dialog.
But I want to point that if want, you can fire it from code.

Something like
saving
that will save a "testing.txt" file with the content "12345".

Joan

Ok, thanks!
Thanks @jguille2, that is very useful to know!