| When making blog or BBS, usually we use hyper link as following: <a href="http://blahblah">file1</a>
But above example may not working in case that the platform is multi-byte character based web page.
Now a days, following method is widely used for security reason. Actually following method is trying to send HTTP header before transferring the file binary. It means that the file URL is automatically hided.
<?php
$dir="/path/to/file/";
if (isset($_REQUEST["file"])) {
$file=$dir.$_REQUEST["file"];
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename="".basename($file).""");
readfile("$file");
} else {
echo "No file selected";
}
?>
In order to download by above module, following calling URL is to be used.
<a href="http://www.yourdomain.com/download.php?file=download.zip">download.zip</a> |