1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
if(isset($_GET["id"])){
$id=(int)$_GET["id"];
$query=$db->prepare('SELECT COUNT(*) AS nbr FROM download WHERE id_download =:id');
$query->bindvalue(':id', $id, pdo::PARAM_STR);
$query->execute() or die(print_r($query->errorInfo()));
if( $query->fetchColumn() > 0)
{
$query=$db->prepare('SELECT fichier FROM download WHERE id_download =:id');
$query->bindvalue(':id', $id, pdo::PARAM_STR);
$query->execute() or die(print_r($query->errorInfo()));
$data=$query->fetch(PDO::FETCH_OBJ);
$chemin = '../pdf/' . $data->fichier;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($chemin));
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($chemin));
readfile($chemin);
exit;
}
}else{
echo '<div class="annonce"><p>"vous n\'avez pas cliqué sur le bon lien"</p></div>';
}
?> |