Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // USE: http://yourdomain/thisfile.php?file=/path/to/file.ext
- // Most of this file was snagged off the web somewhere.
- // Don't timeout when downloading large files
- @ignore_user_abort();
- @set_time_limit(0);
- // Get list name
- $file = $_GET['file'];
- $fullfile = "E:/PATH/TO/FILES/".$file; // REPLACE THIS PATH WITH THE ACTUAL PATH
- // Make sure list is set and file exists
- echo $fullfile;
- if((!$file) or (!file_exists($fullfile))) {
- die("File was not set or did not exist");
- }
- // Create the pointer to our file and open it as read-only binary data
- $fp = fopen($fullfile,'rb');
- // Send headers telling browser to download our passed data
- header("Content-Type: application/octet-stream");
- header("Pragma: no-cache");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Content-Length: " . filesize($fullfile));
- header("Accept-Ranges: bytes");
- header("Content-Disposition: attachment; filename=\"$file\"");
- // Here comes the data
- readfile($fullfile);
- fclose ($fp);
- exit();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement