php 한글파일명 다운로드 가능하게 (익스플로러8 크롬확인함.)
페이지 정보
작성자 미친새 작성일 20-02-21 11:39 조회 21,410 댓글 0본문
<?php
header('Content-Type: text/html; charset=UTF-8');
$downfilename = $_GET['fname'];
$downfiledir = \"../data/file/\";
$downfilename2 = iconv('utf-8', 'cp949//IGNORE', $downfilename);
if(file_exists($downfiledir.$downfilename)){
header(\"Content-Type: application/octet-stream\");
Header(\"Content-Disposition: attachment;; filename=$downfilename2 \");
header(\"Content-Transfer-Encoding: binary\");
Header(\"Content-Length: \".(string)(filesize($downfiledir.$downfilename )));
Header(\"Cache-Control: cache, must-revalidate\");
//header(\"Content-Transfer-Encoding: binary\");
//Header(\"Content-type:file/unknown\");
//Header(\"Content-Description:PHP3 Generated Data\");
header(\"Pragma: no-cache\");
header(\"Expires: 0\");
$fp = fopen($downfiledir.$downfilename , \"rb\");
while(!feof($fp)){
echo fread($fp, 100*1024);
}
fclose ($fp);
flush();
}else {
?>
<script type=\"text/javascript\">alert(\"존재하지 않는 파일입니다.\");history.go(-1);</script>
<?
}
?>
header('Content-Type: text/html; charset=UTF-8');
$downfilename = $_GET['fname'];
$downfiledir = \"../data/file/\";
$downfilename2 = iconv('utf-8', 'cp949//IGNORE', $downfilename);
if(file_exists($downfiledir.$downfilename)){
header(\"Content-Type: application/octet-stream\");
Header(\"Content-Disposition: attachment;; filename=$downfilename2 \");
header(\"Content-Transfer-Encoding: binary\");
Header(\"Content-Length: \".(string)(filesize($downfiledir.$downfilename )));
Header(\"Cache-Control: cache, must-revalidate\");
//header(\"Content-Transfer-Encoding: binary\");
//Header(\"Content-type:file/unknown\");
//Header(\"Content-Description:PHP3 Generated Data\");
header(\"Pragma: no-cache\");
header(\"Expires: 0\");
$fp = fopen($downfiledir.$downfilename , \"rb\");
while(!feof($fp)){
echo fread($fp, 100*1024);
}
fclose ($fp);
flush();
}else {
?>
<script type=\"text/javascript\">alert(\"존재하지 않는 파일입니다.\");history.go(-1);</script>
<?
}
?>
댓글목록 0
등록된 댓글이 없습니다.