Skip to content

Instantly share code, notes, and snippets.

@adnanhz
Last active February 26, 2019 13:00
Show Gist options
  • Save adnanhz/26c2a976d4cf21ddf8f552d178eaea0a to your computer and use it in GitHub Desktop.
Save adnanhz/26c2a976d4cf21ddf8f552d178eaea0a to your computer and use it in GitHub Desktop.
<?php
error_reporting(E_ALL);
$file = $_GET['file']; // a remote file url
$headers = array_change_key_case(get_headers($file, TRUE));
$filesize = $headers['content-length'];
if ( $headers[0] != 'HTTP/1.1 404 Not Found' ) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Length: ' . $filesize);
ob_end_clean();
flush();
readfile($file);
exit;
}
while(1) {
Echo "\n";
if ( connection_status() != 0 ) {
die;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment