این یک روشه که بجای لینک مستقیم به فایلها از لینک غیرمستقیم استفاده کنید مثل این:
http://site-domain/downlaod.php?file=abc.zip
و توی فایل downlaod.php، اول چک کنید که کاربر اجازه دسترسی به فایل رو داره یا نه. بعد دایرکتوری ها رو به اسم فایل اضافه کنید (یعنی آدرس فایل رو اینجوری کنید: dir1/dir2/dir3/files/abc.zip) و در مرحله آخر کد زیر رو اجرا کنید:
$file = 'files/' . $_GET['file'];
if (file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
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($file));
ob_clean();
flush();
readfile($file);
exit;
}
else
{
echo "File Not Found!";
}
با این روش می تونید تو این لالوها یه کانتر هم برای شمارش تعداد داونلود برای فایل یا حتی برای هر کاربر درست کنید.