// download.php
if (isset($_GET['file'])) {
//$file = $_GET['file'];
$file = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_ENCODED);
if (file_exists($file) && is_readable($file) && preg_match('/\.pdf$/',$file)) {
header('Content-Description: File Transfer');
header('Content-type: application/pdf');
header("Content-Type: application/force-download");// some browsers need this
header("Content-Disposition: attachment; filename=\"$file\"");
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file2));
ob_clean();
flush();
readfile($file);
exit;
}else {
header("HTTP/1.0 404 Not Found");
echo "Error 404: File Not Found:
$file
";
header('Refresh: 5; url=http://localhost/zy3.php');
print 'You will be redirected in 5 seconds';
exit ;
}
} else {
header('Refresh: 5; url=http://localhost/zy3.php');
print 'You you shouldn\'t be here ......
redirection in 5 seconds
';
exit;
}
//index.html
Click here to download PDF
Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/zym73g_pymI/14425