<?
$download_size = 312; //다운로드 속도제한 (KB)
$file = "./$download_file"; //서버내 존재하는 파일명
$dnfile = "file_name"; //업로드당시 파일명 - 다운로드시 출력될 파일명
if(!is_file($file)) win_close("파일이 존재하지 않습니다.");
if(eregi("(MSIE 5.0|MSIE 5.1|MSIE 5.5|MSIE 6.0)", $HTTP_USER_AGENT)){
if(strstr($HTTP_USER_AGENT, "MSIE 5.5")) {
header("Content-Type: doesn/matter");
header("Content-disposition: filename=$dnfile");
header("Content-Transfer-Encoding: binary");
header("Pragma: no-cache");
header("Expires: 0");
}
if(strstr($HTTP_USER_AGENT, "MSIE 5.0")) {
Header("Content-type: file/unknown");
header("Content-Disposition: attachment; filename=$dnfile");
Header("Content-Description: PHP3 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
}
if(strstr($HTTP_USER_AGENT, "MSIE 5.1")) {
Header("Content-type: file/unknown");
header("Content-Disposition: attachment; filename=$dnfile");
Header("Content-Description: PHP3 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
}
if(strstr($HTTP_USER_AGENT, "MSIE 6.0")) {
Header("Content-type: application/x-msdownload");
Header("Content-Length: ".(string)(filesize("$file")));
Header("Content-Disposition: attachment; filename=$dnfile");
Header("Content-Transfer-Encoding: binary");
Header("Pragma: no-cache");
Header("Expires: 0");
}
}
else {
Header("Content-type: file/unknown");
Header("Content-Length: ".(string)(filesize("$file")));
Header("Content-Disposition: attachment; filename=$dnfile");
Header("Content-Description: PHP3 Generated Data");
Header("Pragma: no-cache");
Header("Expires: 0");
}
//다운로드실행
if (is_file($file)) {
$fp = fopen($file, "rb");
while(!feof($fp)) {
echo fread($fp, 1024 * $download_size);
sleep(1); // 무조건 속도제한 어떤 파일이나 용량이던 제한
flush();
}
fclose ($fp);
}
else{
win_close("파일이 존재하지 않습니다.");
}
?>
'php, mysql' 카테고리의 다른 글
마감시간 구하기 - 남은시간 구하기 (0) | 2017.04.13 |
---|---|
문자 랜덤출력 (0) | 2017.04.13 |
avg max min sum count / 정렬 (0) | 2017.04.13 |
mysql기본정보 (0) | 2017.04.13 |
cgi 기초문법 (0) | 2017.04.11 |