| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?
- include $_SERVER['DOCUMENT_ROOT']."/common/lib/define.php";
- $local_dir = $_SERVER['DOCUMENT_ROOT'].UPLOAD_PATH;
- // local file that should be send to the client
- $local_file = urldecode($_GET['nm_file']);
- $cd_board = urldecode($_GET['cd_board']);
- $type = urldecode($_GET['type']);
-
- //이부분은 항상 필터링 해야함
- if($type=="job"){
- $filename = $local_dir."job/".$local_file;
- }else{
- $filename = $local_dir."board/board_".$cd_board."/".$local_file;
- }
- // set the download rate limit (=> 20,5 kb/s)
- $download_rate =100;
- // $filename 내에 저장된 파일 풀 경로를 가지고 있다고 가정
- if (!is_file($filename)) {
- die('File Is Empty!!');
- }
- $filepath = str_replace('\\', '/', realpath($filename));
- $filesize = filesize($filepath);
- $filename = substr(strrchr('/'.$filepath, '/'), 1);
- $extension = strtolower(substr(strrchr($filepath, '.'), 1));
- //IE인가 HTTP_USER_AGENT로 확인
- $ie= isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false;
- //IE인경우 한글파일명이 깨지는 경우를 방지하기 위한 코드
- if( $ie ){
- $filename = iconv('utf-8', 'euc-kr', $filename);
- }
- //기본 헤더 적용
- $mime = array('application/octet-stream');
-
- header( "Content-type: application/vnd.ms-excel;charset=UTF-8");
- header('Content-Type: '.$mime);
- header('Content-Disposition: attachment; filename="'.iconv('UTF-8','CP949',$filename).'"');
- header('Content-Transfer-Encoding: binary');
- header('Content-Length: '.sprintf('%d', $filesize));
- header('Expires: 0');
- // IE를 위한 헤더 적용
- if( $ie ){
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- } else {
- header('Pragma: no-cache');
- }
- //해당 파일을 binary로 읽어와 출력
- $handle = fopen($filepath, 'rb');
- fpassthru($handle);
- fclose($handle);
- ?>
|