سلام کاری می تونید انجام بدید استفاده از فابل .htaccess است
خوب اینکه چطور هم به این صورته که شما یک فال .htaccess مینویسید که درخواست ها رو به یک فابل PHP بفرسته
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ download.php?url=$1 [L,QSA]
فایل بالا تمام request ها رو به فایل download.php میفرسته در زمانی که فابل وجود نداشته باشه
پس شما باید فایل های آپلود شده روتوی یه پوشه مثلا files بگذارید و این فابل و فایلdownload.php رو در دایرکوتری جداگونه ای مثلا download
و فابل download.php میونه به صورت زیر باشه:
if(isset($_GET['url'])){
$file = '../files/'.$_GET['url'];
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);
file_put_contents('download.log',@file_get_content s('download.log')."\n$file");
exit;
}else{
if($file == 'API_last_file'){
$lines = @file('download.log');
echo $lines[count($lines)-1];
}else{
http_response_code(404);
echo '404 Not Found!';
}
}
}else{
http_response_code(403);
echo '403 Forbidden error!<br>Your client does not have permission to get this URL from this server. That’s all we know.';
}
و با باز کردن download/API_last_file آخرین فایل دانلود شده اسمش به نمایش در خواهد آمد سوال داشتید می تونید بپرسید