usa la readfile() (o se hai il modulo abilitato X-SendFile di apache).
Esempio:
Codice PHP:
<?php
if(utente_non_autorizzato()){
header('location: forbidden.php');
exit();
}
$file = <il tuo file da scaricare>;
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); // Se i file sono pdf, puoi direttemente mettere il mime di pdf
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
}
?>