Reputation: 403
I keep getting a 404 error saying the file is not on the web server, trying to create an href link to download an excel file.
<p><a href="/ExcelFile.xlsx" download> Click to Download </a></p>
The excel file is in the same directory as the page this is being worked on currently, so there is no file path, I have tried a file path but it gives the same error.
Upvotes: 1
Views: 10897
Reputation: 12817
Firstly create a Downloads
directory under webapp
directory.
webapp -> Downloads -> all the downloadable files
Afterwards you may use the below code
to download into your machine once the link is clicked.
<p>Info: Please Download File
<a href="Downloads/Template.xlsx" download>Download File</a>
</p>
Note: you can add target="_blank" to the download link via a new window.
<p>Info: Please Download File
<a href="Downloads/Template.xlsx" target="_blank">Download File via New Window</a>
</p>
Upvotes: 0
Reputation: 403
Just had to add a folder for files and it worked.
Original:
<p><a href="/ExcelFile.xlsx" download> Click to Download </a></p>
Working:
<p><a href="TestFile/ExcelFile.xlsx" download> Click to Download </a></p>
Upvotes: 2
Reputation: 550
You are saying that ExcelFile.xlxs is in the root folder of the web server / virtualhost.
So if you have a structure where /www is your top level folder, than ExcelFile.xlxs need to be directly in /www and not in a subfolder.
Take a look at absolute and relative paths, this will explain this behavior.
Upvotes: 1