0

I have a page with dynamically generated SVG. I call the save file dialog using data:image/octet-stream. The client would not recognise the URL as an inline-able resource, and prompt a download dialog.

var dataImageUri = "data:image/octet-stream," + encodeURIComponent(svg);
  window.open(dataImageUri);

But then the file is saved without an extension. Expansion and name need to register manually. Can I ask how that extension and name for the file?

Mary
  • 15
  • 6
  • 1
    You could try using the correct MIME type for SVG: `image/svg+xml`. – AmeliaBR Nov 11 '14 at 15:41
  • You could use the html5 `download` attribute, see http://stackoverflow.com/questions/283956/is-there-any-way-to-specify-a-suggested-filename-when-using-data-uri. – Erik Dahlström Nov 12 '14 at 08:01
  • You could try using the correct MIME type for SVG: image/svg+xml - it's not saving the SVG on the local filesystem, this opens the SVG in it's own page. Using html5 download attribute does not suit me to structure my project. – Mary Nov 17 '14 at 16:43

0 Answers0