Set the default save as name for a an or – guest271314 May 19 '17 at 05:19

  • @guest271314 I added a link to a [plnkr](http://plnkr.co/edit/zEGPcVn6ZbMnlTw1ySRw?p=preview) for chrome. The thing you've got to click is this https://i.stack.imgur.com/jyf0k.png – Kaiido May 19 '17 at 05:25
  • The `width`, `height` setting at ` – guest271314 May 19 '17 at 05:27
  • @guest271314, yep their plugin's UI may not be perfect. – Kaiido May 19 '17 at 05:29
  • The firefox approach at firefox appears to return expected result. The "data" URL scheme specification does not appear to mention file name https://tools.ietf.org/html/rfc2397. Where did you find, or did you develop the headers solution? Is setting file name at `data URI` mentioned in one of the w3c mailing lists? – guest271314 May 19 '17 at 05:31
  • http://lists.w3.org/Archives/Public/uri/2010Feb/0069.html from http://stackoverflow.com/questions/283956/is-there-any-way-to-specify-a-suggested-filename-when-using-data-uri – guest271314 May 19 '17 at 05:43
  • @guest271314, yep that was an attempt to use this "never implemented in specs" feature, and I was a bit surprised to see it working in FF to be honest. – Kaiido May 19 '17 at 06:20
  • This solution does work for FireFox and Chrome sets it to 'download' which is an improvement over a uuid so I marked the answer as accepted. For IE, I had to use a different strategy (window.navigator.msSaveOrOpenBlob) which does let me control the suggested name although forces the user to save whether they want to or not. Bottom line is that the answer to my original question is "not really". Hopefully the FF syntax will become a standard. – Brian Deterling May 22 '17 at 21:19
  • 1
    In Firefox it will be downloaded as "document.pdf" in Chrome as "download.pdf" – connectedMind Aug 12 '21 at 06:31
  • @connectedMind yes, in 4 years things have probably changed, but the main point stays the same anyway: If it's important, don't rely on the browser's internal plugin. And actually, this question is a duplicate of https://stackoverflow.com/questions/53548182/can-i-set-the-filename-of-a-pdf-object-displayed-in-chrome/53593453#53593453 where I did propose a better solution, which still seems to work as of today. – Kaiido Aug 12 '21 at 07:37
  • @connectedMind actually I was a bit fast, it **doesn't** work in Chrome either... – Kaiido Aug 12 '21 at 08:00
  • 2

    Is there any way around this so that I can control the name?

    No. You cannot control the name of a file stored at user local filesystem.

    You can use <a> element with download attribute set to suggested file name. If user selects to download offered file user can change the file name at any time before or after downloading file.

    window.onload = () => {
      let blob = new Blob(["file"], {
        type: "text/plain"
      });
      let url = URL.createObjectURL(blob);
      let a = document.createElement("a");
      a.href = url;
      a.download = "file.txt";
      document.body.appendChild(a);
      console.log(url);
      a.click();
    }

    At chrome, chromium browsers you can use requestFileSystem to store Blob, File or Directory at LocalFileSystem, which writes file to browser configuration directory, or other directories within user operating system. See

    Community
    • 1
    • 1
    guest271314
    • 1
    • 15
    • 104
    • 177