I'm trying to place a button that, when clicked, downloads the file aaa.txt.
I have that file on the same folder as my index.html.
I've tried this:
<a href="aaa.txt" download>aaa</a>
<a target="_blank" href="aaa.txt" download>aaa</a>
<a href="aaa.txt" download >aaa</a>
But none seem to work. When clicked, chrome downloads a aaa.htm and says "error:file not found"
Also, I'm on a private server, not just running the html file.
CodePudding user response:
It is quite simple you just need to specify the route more accurately, by adding a forward slash "/" before aaa.txt
<a href="/aaa.txt" download>aaa</a>
for more info, you can refer w3school
CodePudding user response:
It deepens from where you generate the link:
/ = root of the current app (/);
./ = current directory (/subfolder/subfolder/);
../ = parent of the current directory (/parentFolder/).
Means if you have only a index.html file in root then you need only /filename.ext
. In your case:
aaa