Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
Created March 11, 2011 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sp3c73r2038/865673 to your computer and use it in GitHub Desktop.
Save sp3c73r2038/865673 to your computer and use it in GitHub Desktop.
transfer file to page
<?
$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