0

I need to save the file that is on my hard drive.

File address: /home/mk/proj1/1.txt

Program address: /home/mk/proj2/

I try to save:

new dom.AnchorElement(href: '/home/mk/proj1/1.txt')
 ..setAttribute("download", '1.txt')
 ..click();

Displays information about saving, but writes: Failed! No file.

How to save a file?

VINET
  • 641
  • 1
  • 7
  • 28

1 Answers1

1

There is not really a way to save a file in the browser (except perhaps limited support for temporary files)

You can search for JavaScript solutions. They will be quite similar for Dart in the browser.

For example JavaScript: Create and save file

If you want to store a file on the client machine, you can provide a download link.

See also How to force a Download File prompt instead of displaying it in-browser with HTML?

To provide a download link for data that is available in the browser clients code instead of a server file, you can use a data url.

See also https://stackoverflow.com/a/29691487/217408

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567