Whenever I use this script to download a file, I can't see the total size and the speed while downloading... I want to to make it look more like the 'direct download link'. The purpose of this script is to hide the direct download link restrict direct downloading and other download behavior, like bots. Think of mediafire, rapidshare, megaupload etc.
The script we have now works but is not displayed as how it is displayed when you download from a normal download link, I will post a screenshot of what's happening:
I hope this screenshot helps, because I've searched the internet for hours and can't seem to find a solution to this :(.
if (isset($_GET['file'])){
$file = $_GET['file'];
$path = '/home/user/domains/domain.com/files/upload/';
$filepath = $path.$file;
if (file_exists($filepath)){
set_time_limit(0); // for slow connections
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename=\"$file\"");
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($filepath));
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Expires: 0');
readfile($filepath); // send file to client
}
else{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
}
}else{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
}