How to give a download option [closed]
I am making a site on which I'll give users the option to download software.
I want to know what to do for that.
For example:
To download xyz software click here
and if the user clicks on it, the download starts.
<p>You can download <a href="/url/to/the/file/to/download">the thing that you want</a>
You can use this function:
function download($path, $filename) {
header('Content-Type: application/force-download');
header('Content-Disposition: attachment;filename="'. $filename . '"');
$fp=fopen($path . "/". $filename, 'r');
fpassthru($fp);
fclose($fp);
}
Next, you have to set values for $path & $filename & call the above function like this:
$path = $_SERVER['DOCUMENT_ROOT']."/your_download_directory";
$filename = xyz_software.zip;
download($path, $filename);
精彩评论