0

I have tried to make a link that makes you download a file when you click it, but when i try it, it only opens the link and starts the file in the browser. Im using internet Explorer by the way.

Code:

<html>
<head>
    <title>Test Website</title>
</head>

<body>
    <h1>My Games:<br></h1>
    <a href="http://erikwallstrom.16mb.com/AdventureGame.swf.swf">My Epic Game</a> 
</body>
</html>

(Don't mind the "AdventureGame.swf.swf, i accidently named it like that). Why doesn't the file download?

Nvm, i uploaded zip folders with the files inside and now it is downloading correctly.

Erik W
  • 2,590
  • 4
  • 20
  • 33
  • possible duplicate of [(HTML) Download a PDF file instead of opening them in browser when clicked](http://stackoverflow.com/questions/6794255/html-download-a-pdf-file-instead-of-opening-them-in-browser-when-clicked) – Mudassir Hasan Nov 23 '14 at 12:26
  • The answers given there doesn't work for me though... – Erik W Nov 23 '14 at 12:42
  • Your browser will try to remain in context as long as possible, basically trying to open everything by himself. The only reason why it even opens the file is because it thinks it can handle .swf files. The only REAL way of doing this without resorting to HTML5-only features is server side by modifiying the appropriate headers. – Eugen Timm Nov 23 '14 at 12:43
  • And how would i do that? – Erik W Nov 23 '14 at 12:45
  • Depends on what your server side technology is. If you serve the files directly it is not as easy: Basically if your server path is /files/whatever.pdf and you access them directly through yourserver.net/files/whatever.pdf it'll be a litte harder. What server side language, if any, do you use? – Eugen Timm Nov 23 '14 at 12:49

2 Answers2

0

Try adding a download at the end of the opening tag:

<a href="http://erikwallstrom.16mb.com/AdventureGame.swf.swf" download>My Epic Game</a>

http://jsfiddle.net/wfmhh2o2/

irrelephant
  • 4,091
  • 2
  • 25
  • 41
0

You could use the HTML5 download attribute like so:

<a href="path/to/file" download>Click here to download</a>

This opens a "save as" dialog regardless of file type without taking you away from the page.

Force a browser to save file as after clicking link

[EDIT] Try this : How to start automatic download of a file in Internet Explorer?. If you have the last version of IE it should work

Community
  • 1
  • 1
Opras
  • 11
  • 2
  • I've tried it now, but no "save as" dialog appears, the browser just opens the file. Do you Think it has something to do with internet Explorer? – Erik W Nov 23 '14 at 12:33