Skip to content

Instantly share code, notes, and snippets.

@wokamoto

wokamoto/gist:9066721

Last active Aug 29, 2015
Embed
What would you like to do?
<?php
$mime_type = 'application/pdf';
$file_path = '/path/to/pdf';
// for IE 8 ( see http://support.microsoft.com/kb/323308/ja )
$expires = 30;
header("Last-Modified: ". gmdate("D, d M Y H:i:s", filemtime($file_path)). " GMT");
header("Expires: " . date(DATE_RFC1123, time() + $expires));
header("Pragma: cache");
header("Cache-Control: max-age={$expires}");
header("Cache-Control: cache");
// for IE 8
header('Content-Disposition: inline; filename="'.basename($file_path).'"');
header('Content-Length: '.filesize($file_path));
header('Content-Type: '.$mime_type);
readfile($file_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.