I am trying to use the download attribute, it works on Firefox but when I run the same HTML file in Chrome it does not work.

This is my html file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Download</title>
  </head>
  <body>

      <a download="mylogo" href="san-francisco.jpg"><img src="san-francisco.jpg" alt="Photo" width="104" height="142"></a>

  </body>
</html>

1 Answers

2
Community On

Try this:

<a target="_blank" download="mylogo" href="san-francisco.jpg" title="ImageName">
    <img alt="ImageName" src="san-francisco.jpg" width="104" height="142">
</a>

If it wasn't for this:

download attribute:

If the HTTP header Content-Disposition: is present and gives a different filename than this attribute, the HTTP header has priority over this attribute.

If this attribute is present and Content-Disposition: is set to inline, Firefox gives priority to Content-Disposition, like for the filename case, while Chrome gives priority to the download attribute.

Source

HTTP-Header Content-Disposition