Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function download_contents($content, $type, $name, $size, $force_download = false) {
- if(connection_status() != 0) return false; // check connection
- if($force_download) {
- header("Cache-Control: public");
- } else {
- header("Cache-Control: no-store, no-cache, must-revalidate");
- header("Cache-Control: post-check=0, pre-check=0", false);
- header("Pragma: no-cache");
- } // if
- header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Content-Type: $type");
- header("Content-Length: " . (string) $size);
- // Prepare disposition
- $disposition = $force_download ? 'attachment' : 'inline';
- header("Content-Disposition: $disposition; filename=\"" . $name) . "\"";
- header("Content-Transfer-Encoding: binary");
- print $content;
- return((connection_status() == 0) && !connection_aborted());
- }
Add Comment
Please, Sign In to add comment