Created
March 11, 2011 09:44
-
-
Save sp3c73r2038/865673 to your computer and use it in GitHub Desktop.
transfer file to page
This file contains hidden or 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
<? | |
$expire=180; | |
$showname = "testfile.tgz"; | |
$file = '/var/www/snippet/index.html'; | |
$length = filesize($file); | |
/* the file type is accroding to the mime type, not concern on file name */ | |
header('Content-Description: File Transfer'); | |
header('Content-Type: text/html'); | |
header('Content-Disposition: attachment; filename='.$showname); | |
header('Content-Transfer-Encoding: binary'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
header('Pragma: public'); | |
header('Content-Length: ' . $length); | |
ob_clean(); | |
flush(); | |
readfile($file); | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment