Click here to Skip to main content
14,981,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have application where i want to download file on link click

My HTML Code
<a href="Docs/Test.pdf" download>Download</a>

This is working fine because the Docs folder in same project, but when i want to give local path like

<a href="C:\Users\xyz\Downloads\Test.pdf" download>Download</a>

this line of code failing to download, how to give local path to download properly?

Please help me

thanks in advance...

What I have tried:

My HTML Code which is working fine

<a href="Docs/Test.pdf" download>Download</a>

My HTML Code which is not downloading file
<a href="C:\Users\xyz\Downloads\Test.pdf" download>Download</a>
Updated 16-Mar-17 22:52pm

Please use "file:///" before giving the path of the directory. Also, use "/" & "\" properly.

Here is the working solution in my system,

<a href="file:///C:\Users\105800\Downloads\Systems - Casinolink - Slot.pdf" download>Download</a>

Please revert back for any issues.
Ravi Sargam 17-Mar-17 3:04am
still the same problem not downloading.... failed to download...
Prateek Dalbehera 17-Mar-17 3:06am
Then there is problem with the path given. BTW which browser you are using, i tested in chrome. Also specify the error message
Ravi Sargam 17-Mar-17 3:09am
using Chrome and message is failed-Network error
Prateek Dalbehera 17-Mar-17 3:18am
Please cross verify the path & back/forward slashes, still if you are not able to download then there may some issues with your browser. Some links below which may help
Member 3653749 4-Mar-20 16:44pm
It does not work for UNC path
Please use "file://///" instead of "file:///", once you get the hyperlink right-click on it ,choose "copy link address" and paste it in new window, the file will automatically gets downloaded

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900