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

My HTML Code
HTML
<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

HTML
<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

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


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

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

Here is the working solution in my system,

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


Please revert back for any issues.
 
Share this answer
 
Comments
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

http://stackoverflow.com/questions/39677280/chrome-failed-network-error
https://superuser.com/questions/836345/why-is-my-chrome-failing-to-download-some-files
https://www.codeproject.com/Questions/1139675/Failed-network-error-while-downloading-the-files-f
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
 
Share this answer
 

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