eh eh... c'hai anche ragione! :-)
Codice PHP:
function snd_file($name, $path_local) {
// $name => nome del file da inviare
// $path_local => percorso per raggiungere il file
// $file_type => mime/type
// label => permette di impostare una label + logica per il file
$status = FALSE;
$path = "$path_local/".$name;
if (!is_file($path) or connection_status()!=0){
echo "
- ".$path." -
";
return(FALSE);
}
if (!is_null($label))
{$nomefile = $label;}
else
{$nomefile = $name;}
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
#header("Content-type: application/$file_type");
header("Content-Disposition: attachment; filename=".$nomefile."");
header("Content-length: ".(string)(filesize($path)));
header("Last-Modified: " . gmdate("D, d M Y H:i:S") . " GMT");
// always modified
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
print(fread($file, 1024*8));
flush();
}
$status = (connection_status()==0);
fclose($file);
}
return($status);
}