Ciao,
allego tutto lo script...
Codice PHP:
<?php
include("config/include_funzioni.php");
$db = connetti_db(CL_DB);
$email = check_sessione($db,$PHPSESSID);
$item = GetItem($db,'Select * from dr where id='.$_REQUEST['id']);
// Verifica che l'utente è autorizzato
//$user = GetItem($db,"Select * from utenti where email = '$email'");
//if (strtoupper($user['dr_autorizzato']) > 0)
// {
$file = $item['allegato'];
$documento = $item['documento'];
$percorso = PATH_ALLEGATI_DR;
$percorso_file = $percorso.$file;
$dimensione_file = filesize($percorso_file);
$download = $item['download'] + 1;
$stringa_sql = "UPDATE dr SET download = $download where id = ".$item['id'];
$update_item = mysql_query($stringa_sql,$db);
check_sql();
// OK con PDF
header("Content-Type: application; name=".$file);
header("Content-Transfer-Encoding: binary");
//header("Content-Length: ".$dimensione_file);
header("Content-Disposition: attachment; filename=".$documento);
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Pragma: public");
readfile($percorso_file);
// Log
//set_log($db,$email,'DR',$item['titolo'],'Download documento');
//}
//else
// print '<FONT style="font-size:13px" color="#000000" face="Verdana">Spiacente ma [b]'.$user['email'].'[/b] non è autorizzata al download.';
?>