Last active
February 26, 2019 13:00
-
-
Save adnanhz/26c2a976d4cf21ddf8f552d178eaea0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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