1

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.

user20929302
  • 383
  • 1
  • 4
  • 14

3 Answers3

2

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>
user20929302
  • 383
  • 1
  • 4
  • 14
1

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.

0

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>
Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51