0

a href download doesn't work with some extensions or with files without extensions.

Works fine:

<a href="/test.txt" download>test.txt</a>

Doesn't work:

<a href="/test" download>test</a>
<a href="/test.exe" download>test.exe</a>

Also doesn't work with: download="fileName", target="_blank"

Is there way to force download files with other extensions?

rmk
  • 69
  • 1
  • 7

3 Answers3

1

i will recommend to add a direct link of dropbox or anyother media sharing site as it is secured by http and can be allowed to download through any browser. or use this syntax for HTML5

<a href="/test" download="test">Download</a>
Muhammad Junaid
  • 180
  • 1
  • 11
1

Thx for help, HTML5 works fine with any file extensions. I had problem with my web-server configuration (IIS doesn't allow download unregistered MIME types).

Solution described here: using IIS to serve files without extension as plain text

rmk
  • 69
  • 1
  • 7
0

Only in modern browsers that support HTML5 the following is possible:

<a href="/test" download>Download</a>

or

<a href="/test" download="test">Download</a>

If HTML5 is not supported :

<a href="/test.txt" download="test">Download</a>

With _target:

<a href="/test.txt" target="_blank">Download</a>

With the download attribute you can use it to change the name of the file actually being downloaded like this:

download="name of the file"

For .exe all you need to do is a simple anchor tag:

<a href="/test.exe">Download Executable</a>