0

I'm having trouble with what seems like should be a very rudimentary task. Basically, I've got a plain HTML page that I want to download a file through. (Well actually there will be a page with more content and interesting to see, but I've stripped out everything to isolate the problem for now.) I'm trying to use the download attribute in an anchor tag to download a file. I've tried it with a number of file types and my browser doesn't seem to be using the download attribute because the behavior is the same regardless of whether or not I include download in the tag. Here's what I have right now:

  1 <!DOCTYPE HTML>
  2 <html>
  3 <head>
  4     <title>Title Here</title>
  5     <meta charset = "UTF-8"/>
  6 </head>
  7 <body>
  8   <p>
  9     <a href="test.txt" download>Download</a>                             
 10   </p>
 11 </body>
 12 </html>

Opening the page with Chrome and Safari both give the same results - a photo will link to the photo, a text file will link to the text file to be opened in the browser like the photo, and a word doc will download (with or without the download attribute) but I would like to have all file types download when the attribute is included. Has anyone run into an issue like this? Based on everything I've read about the download attribute it seems like this should work with pretty much all modern browsers now that HTML5 has been the standard for some time. Is it possible that I've got some local settings that are causing this?

Thanks!

1 Answers1

-1

A similar question has been posted before:

PDF file not downloading with HTML5 download attribute

The browser will try opening the pdf file because of accessibility reasons.

yarex
  • 43
  • 8