Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.