Eccoti il codice, incluso il controllo
Codice PHP:
<?
$_GET['file'] = trim(htmlentities($_GET['file'], ENT_QUOTES));
$path = './files/' . $_GET['file'];
$size = filesize($path);
if ($size == FALSE)
{
die();
}
$file = $_GET['file'];
$check = substr($file, strlen($file) - 3, strlen($file));
if($check != "rar" AND $check != "zip")
{
die('Stai tentando di scaricare un file non scaricabile');
}
else
{
@header("Content-Type: application/octet-stream");
@header("Content-Length: " . $size);
echo fread($path, $size);
}
?>