I'm making a file sharing site for the fun. Trying to make it so that when I hit download, it starts the download. Instead of just a link to /files/$file
im trying to do a header redirect:
download.php
/**
* File Download
*/
$query = mysql_query("SELECT id,name,desc FROM files WHERE id = ".intval($_GET['id']));
$row = mysql_fetch_assoc($query);
$file = $row['name'];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
Filename: <?=$row['name']?>
Desc: <?=$row['desc']?>
<a href="#">Download this file</a>
Im stuck here, what should I do next?
thank you