Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://stackoverflow.com/questions/6914912/streaming-a-large-file-using-php
- <?php
- // the file you want to send
- $path = "path/to/file";
- // the file name of the download, change this if needed
- $public_name = basename($path);
- // get the file's mime type to send the correct content type header
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $mime_type = finfo_file($finfo, $path);
- // send the headers
- header("Content-Disposition: attachment; filename=$public_name;");
- header("Content-Type: $mime_type");
- header('Content-Length: ' . filesize($path));
- // stream the file
- $fp = fopen($path, 'rb');
- fpassthru($fp);
- exit;
- ?>
Add Comment
Please, Sign In to add comment