Downloading A File From A Php Server Via A Website
I have physical files which I want users to download on my website. The files are located at: C:/xampp/htdocs/myfile/uploads/* I need a PHP script which can download files dynamica
Solution 1:
Download link
<ahref="magic.php?file=<?phpecho urlencode($row['name']); ?>">Download</a>
magic.php page
<?php$file = 'C:/xampp/htdocs/myfile/uploads/'.urldecode($_GET['file']);
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
Post a Comment for "Downloading A File From A Php Server Via A Website"