Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. "Save Image As" File Name for Inline Data URLs [Solved]

"Save Image As" File Name for Inline Data URLs [Solved]

Scheduled Pinned Locked Moved Web Development
javascriptdatabasehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Skippums
    wrote on last edited by
    #1

    I am generating a number of images in javascript using canvas elements, then using the canvas.toDataURL function to set the source on image elements that are displayed to the client. I am using image elements since I want the user to be able to save the image (only available in Firefox on canvas elements, currently). The problem is that, when the user clicks "Save Image As", the name of the file comes up as "download.png" (Chrome 35), "index.png" (FF 30), "untitled.png" (IE 11), or "Unknown" (Safari 5.1.7). I have attempted to set the id, name, alt, and title attributes on the img tag, all of which appear to have no effect on the save as name. Is there any way in any of the major browsers to set a file name when the user attempts to save an image who's source is an inline data url? Thanks,

    Sounds like somebody's got a case of the Mondays -Jeff

    Richard DeemingR 1 Reply Last reply
    0
    • S Skippums

      I am generating a number of images in javascript using canvas elements, then using the canvas.toDataURL function to set the source on image elements that are displayed to the client. I am using image elements since I want the user to be able to save the image (only available in Firefox on canvas elements, currently). The problem is that, when the user clicks "Save Image As", the name of the file comes up as "download.png" (Chrome 35), "index.png" (FF 30), "untitled.png" (IE 11), or "Unknown" (Safari 5.1.7). I have attempted to set the id, name, alt, and title attributes on the img tag, all of which appear to have no effect on the save as name. Is there any way in any of the major browsers to set a file name when the user attempts to save an image who's source is an inline data url? Thanks,

      Sounds like somebody's got a case of the Mondays -Jeff

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      There's nothing in the RFC[^], and Wikipedia[^] explicitly states:

      Data URI scheme[^]

      Data URIs do not carry a file name as a normal linked file would. When saving, a default file name for the specified MIME type is generally used.

      The only suggestion I've seen is to use an <a> tag with the download attribute[^], but this won't work in any version of IE[^].

      <a href="data:image/png;base64,..." download="ImageFileName.png">download the image</a>


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups