<?php
//------------------------------------------------------------------------------------ 파일 다운로드
$filepath = './image.html';
$filesize = filesize($filepath);
$path_parts = pathinfo($filepath);
$filename = $path_parts['basename'];
$extension = $path_parts['extension'];
header("Pragma: public");
header("Expires: 0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $filesize");
ob_clean();
flush();
readfile($filepath);
//------------------------------------------------------------------------------------ 문자를 파일로 다운로드
$contents = "aaaaaaaaaa 나는 사람이다";
$filename = "Report_".date("Ymd").".html";
$filesize = strlen($string);
header("Pragma: public");
header("Expires: 0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $filesize");
ob_clean();
flush();
echo $contents;
?>
'PHP' 카테고리의 다른 글
json_decode (0) | 2017.12.15 |
---|---|
PHP 5.16 to PHP 5.3.29 (0) | 2015.05.12 |
IP 체크하여 영문 혹은 한글 사이트로 분기 시키기 (0) | 2013.08.20 |
PHP 소스 암호화 php_screw (0) | 2012.10.08 |
fpdf (0) | 2012.10.08 |