반응형
// $Path : 파일의 풀패스(http://..보다는 실제 상대디렉토리로 지정해주는게 좋다)
// $user_file : 파일명.
header("Cache-control: private");
if (eregi("(MSIE 5.5|MSIE 6.0)", $HTTP_USER_AGENT)) {
Header("Content-type:application/octet-stream");
Header("Content-Length:".filesize($Path));
Header("Content-Disposition:attachment;filename=".$user_file);
Header("Content-Transfer-Encoding:binary");
Header("Pragma:no-cache");
Header("Expires:0");
} else {
Header("Content-type:file/unknown");
Header("Content-Length:".filesize($Path));
Header("Content-Disposition:attachment; filename=".$user_file);
Header("Content-Description:PHP3 Generated Data");
Header("Pragma: no-cache");
Header("Expires: 0");
}
if (is_file($Path)) {
$fp = fopen($Path, "rb");
if (!fpassthru($fp)) fclose($fp);
clearstatcache();
} else {
echo "해당 파일이나 경로가 존재하지 않습니다.";
}
// php school에서 팁에 올라와있는거 정리했숩니다.
반응형
'WEB > CGI' 카테고리의 다른 글
ASP[VBS], PHP, Perl, MSSQL, JSP 통화표시 숫자에 콤마 (0) | 2010.10.21 |
---|---|
ASP 에서 쿠키 <-> PHP에서 쿠키 (0) | 2010.10.21 |
php for windows 로 메일보내기 (0) | 2010.10.21 |
PHP 숫자에 점찍기, 소수점이하 '..'처리 (0) | 2010.10.21 |
PHP 날짜 더하기, 날짜 비교하기 (0) | 2010.10.21 |