-
php 파일 다운로드 (pdf 파일 다운로드 예), php file downloadWeb/PHP 2017. 4. 6. 17:59
php file download
<?
include"./system.php";
$dir = './duri/goods/pdf';
$filekeyname = $_GET['filekeyname'];
$fpath = $dir."/".$filekeyname;
$filename = preg_replace("/\s| /",'',$_GET['filename']).".pdf";
//echo $fpath;
//exit;
if (file_exists($fpath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename=' . urlencode(basename($filename)));
// 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: ' . filesize($fpath));
ob_clean();
flush();
readfile($fpath);
exit;
}
?>
'Web > PHP' 카테고리의 다른 글
[PHP]문자열 자르기, 나누기, 원하는 문자 가져오기 (0) 2019.06.14 [PHP]배열에 동작하는 반복문 (0) 2019.06.13 PHP세션 및 쿠키 만료 처리 (0) 2018.12.05 해당 주차의 첫 요일(일)과 마지막 요일(토) 구하기 php (0) 2017.03.13 php foreach 반복문 (0) 2016.07.07