0

I am building a website with physics simulation tutorials. One of this, generates data and plots it on a canvas element. Tough it is possible to save the image from the canvas as .png I would like the user could be provided with the possibility to download generated data as well. This is not a question regarding downloading existing files an a server. Rather the aim here is to dump some 2d-array data into a file (in csv format) that the user can download on the push of a button which opens a 'Save as' dialog box.

DorinPopescu
  • 715
  • 6
  • 10
  • possible duplicate of [Using HTML5/Javascript to generate and save a file](http://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file) – Jordan Running Feb 04 '15 at 23:49

1 Answers1

0

Depending on the browser the client is using, a simple a.download with Blob URLs could do. If you target more browsers, I'd adwise the use of something like FileSaver.js to get multi browser support (Here is a demo).

xen
  • 625
  • 1
  • 7
  • 18