When I click download button, it link to new thanks webpage and after 2 sec start download .csv file from SD card.
Instead of downloading the file, it getting displayed on browser. Below is my code.
How can I get download option every time? Please no php code, as I am new to html.
I don't want to save using save as option after .csv file open browser.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Monitoring System</title>
<link href="/mchp.css" rel="stylesheet" type="text/css" />
<script src="/mchp.js" type="text/javascript"></script>
</head>
<body>
<div id="shadow-one">
<div id="shadow-two">
<div id="shadow-three">
<div id="shadow-four">
<div id="page">
<div>
<div>
<div>
<div id="title">
<div class="right">Interface</div>
<div class="left">Overview</div>
</div>
<div id="content">
<h1>Monitoring System</h1>
<table style="padding-left: 10px;">
<div id="lcontent">
<div id="llogindiv" ><h1>Thanks for downloading...</h1></div>
<META HTTP-EQUIV="refresh" CONTENT="2;~GetEventFile~;";>
</table>
</div>
</div>
<div class="spacer"> </div>
<div id="footer">Copyright © Monitoring System</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
~GetEventFile~ will give me file name at run time.
At this point the safe solution is to set the response headers.
Modern browsers support download
attribute for anchor elements which is used to specify the name of the file as it will be downloaded:
<a href="http://sstatic.net/stackexchange/img/logos/so/so-logo.png" download="logo.png">Download SO Logo</a>
You can use the download attribute
<a href="Document.pdf" download="Document.pdf">Download the pdf</a>
This a HTML5 Attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With