HTML: Not downloading file on click - html

I wish to download excel file on click/trigger:
<a href="/download/test.xlsx" download>
<button id = 'download' type="button" class="btn btn-outline-info" onclick="">
Download File
</button>
</a>
This while clicking is failing as it is trying to go to "file:///C:/download/test.xlsx".
What is wrong here?

You code is correct except the file file path.
You need to have the file in the same folder in which you have your html file.
So if the files name is some_text.txt which is in the same folder, then use the following code:
<a href="some_text.txt" download>
<button id = 'download' type="button" onclick="">
Download File
</button>
</a>
It worked for me, it will also work for you.
You could also try replacing it with images also.
For more check this link: https://www.w3schools.com/howto/howto_html_download_link.asp

Related

How to add download .app file from html button

I cannot figure this one out.
Here's my code.
<a class="button button-primary" href="NewApp.app" download="NewApp"><i class="fa fa-download" style="margin-top: 2px;"></i> Download</a>
The app is called NewApp.
The NewApp.app file is in the same as index.html.
This button just downloads a random file 'NewApp.html' which doesn't exist.
How do I fix this?
Have you tried, instead of download="NewApp", just download. In HTML, I believe, to download a file, you must do the following:
<a href="foo.app" class="button button-primary" download>Download the app!</a>
It will automatically download the file that the href attribute is pointing towards. I hope this helps.

Unexpected not workable download button

I have the following code based others tutorials (look at the picture):
When I run the code through the browser, the button is appeared but when I click on it the pdf does not downloaded (or appeared to other html page).I have checked if there is any problem with the file link but when I run it through browser is appeared to browser properly. I must note that this code is included to php file ( for example file.php).CODE
HTML:
<button class="etc etc">
<i class="fa fa-download"></i>Katabaste Odygies
</button>
Try changing your anchor tag to look like this:
<button class="etc etc">
<a href="itdb/a.pdf">
<i class="fa fa-download"></i>Katabaste Odygies
</a>
</button>
When people click the <i> tag, it is not inside the <a> so the download is not being triggered.
Also, you are referencing the file incorrectly for a web server.

Download file from local path / server path using html tag <a> (newbie)

I am trying to download a file on image click using following code -
<a href="file:///D:\dir\a.pdf" target="_self" download>
<i class="glyphicon glyphicon-download-alt" id="download"> </i>
</a>
If I add any html url, it's working fine but here it dosen't do anything. Please help
[EDIT]
I have even tried -
<a href="file:///D:/dir/a.pdf" target="_self" download>
<i class="glyphicon glyphicon-download-alt" id="download"> </i>
</a>
Using file:///... will only work if your HTML page is also local (opened via file:/// also). If that is not the case look at: http://www.websina.com/bugzero/kb/browser-file-url.html

Button link redirect issue

I have this button on my website which I am using to redirect to another page when clicked using the onclick function. The problem is, when it is clicked, it just shows the 404 page? Any ideas why this is happening?
<button class="btn btn-sm btn-badge" type="button" onclick="location.href = 'user_page.php&show=1?badge=Available';"><i class="fa fa-sort" style="color:#963"></i> Available </button>
It seems like you have your link incorrect - it should be ? first and then &.
Like this:
user_page.php?show=1&badge=Available
That should then solve your problem.
Try this :
onclick="javascript:location.href='user_page.php&show=1?badge=Available'"

PDF link does not open

I placed this link inside a page to open a pdf, but it does not open. When I inspect the dom and click the highlighted href, it does open. Any suggestions?
<div class="document-wrapper">
<a alt="One Pager" class="document btn btn-link" href="/assets/asset_contents/5203/original/test.pdf?1405610951">One Pager</a>
</div>
try this:
for open the pdf in a new windows
<a target=\"_blank\" href="example.pdf" title="some title"></a>
if you want to put some linked image try this:
<a target=\"_blank\" href="example.pdf" title="some title"><img src="adobepdf.png" height="30" width="30"></a>
good luck