I have an issue with downloading files with PHP. I think the download.php is not working and I need assistance. when I click download button, instead of downloading the file, it is trying to open it like a page and says it is not available in the server, yet it is there. this is the error message
website button
<a href="download.php?id=<?=$results['file'];?>" ><button
class="btn1">download</button></a>
download.php
if (isset($_POST['id'])) {
$stat=$conn->prepare("SELECT * FROM complete WHERE id=?");
$stat->bindParam(1,$id);
$stat->execute();
$data = $stat->fetch(PDO::FETCH_ASSOC);
$file = 'files/'.$data['filename'];
if (file_exists($file)) {
header('Content-Description:'.$data['description']);
header('Content-Type:'.$data['type']);
header('Content-Disposition:'.$data['disposition'].';filename="'.basename($file).'"');
header('Expires:'.$data['expires']);
header('Cache-Control:'.$data['cache']);
header('Pragma:'.$data['pragma']);
header('Content-Length:'.filesize($file));
readfile($file);
exit();
}
}
?>