메뉴 건너뛰기

프로그램언어

조회 수 19794 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<?
   //First, see if the file exists
   if (!is_file($file)) { die("<b>404 File not found!</b>"); }

    //Gather relevent info about file
   $len = filesize($file);
   $filename = basename($file);
   $file_extension = strtolower(substr(strrchr($filename,"."),1));

    //This will set the Content-Type to the appropriate setting for the file
   switch( $file_extension ) {
     case "pdf": $ctype="application/pdf"; break;
     case "exe": $ctype="application/octet-stream"; break;
     case "zip": $ctype="application/zip"; break;
     case "doc": $ctype="application/msword"; break;
     case "xls": $ctype="application/vnd.ms-excel"; break;
     case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
     case "gif": $ctype="image/gif"; break;
     case "png": $ctype="image/png"; break;
     case "jpeg":
     case "jpg": $ctype="image/jpg"; break;
     case "mp3": $ctype="audio/mpeg"; break;
     case "wav": $ctype="audio/x-wav"; break;
     case "mpeg":
     case "mpg":
     case "mpe": $ctype="video/mpeg"; break;
     case "mov": $ctype="video/quicktime"; break;
     case "avi": $ctype="video/x-msvideo"; break;

      //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
     case "php":
     case "htm":
     case "html":
     case "txt": die("<b>Cannot be used for ". $file_extension ." files!</b>"); break;

      default: $ctype="application/force-download";
   }

    //Begin writing headers
   header("Pragma: public");
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: public"); 
   header("Content-Description: File Transfer");
   
   //Use the switch-generated Content-Type
   header("Content-Type: $ctype");

    //Force the download
   $header="Content-Disposition: attachment; filename=".$filename.";";
   header($header );
   header("Content-Transfer-Encoding: binary");
   header("Content-Length: ".$len);
   @readfile($file);
   exit;
?>

  1. No Image 12Apr
    by
    2014/04/12 Views 20395 

    PHP 에서의 소켓(Socket) 통신

  2. No Image 26Mar
    by
    2014/03/26 Views 19490 

    PHP 세션에서 시작, 변수등록, 변수삭제, 부수기

  3. No Image 26Mar
    by
    2014/03/26 Views 17716 

    어떤 스마트폰으로 접속했는지 알아내는 소스 , (안드로이드 아이폰 )

  4. No Image 26Mar
    by
    2014/03/26 Views 20704 

    PHP 소스 : 이미지 리사이즈, 섬네일

  5. No Image 26Mar
    by
    2014/03/26 Views 19434 

    네이버 지도 api php버전

  6. No Image 26Mar
    by
    2014/03/26 Views 19535 

    Drag/Drop HTML elements

  7. No Image 26Mar
    by
    2014/03/26 Views 19667 

    이미지 워터마크 구현

  8. No Image 26Mar
    by
    2014/03/26 Views 21623 

    특수문자 없애는 정규표현식

  9. No Image 26Mar
    by
    2014/03/26 Views 19522 

    jQuery 개발자를 위한 메모 - 레퍼런스

  10. No Image 26Mar
    by
    2014/03/26 Views 19064 

    JSON and JavaScript usage

  11. No Image 26Mar
    by
    2014/03/26 Views 19257 

    jQuery 개발자를 위한 메모 - 플러그 인

  12. No Image 26Mar
    by
    2014/03/26 Views 20356 

    웹에서 Excel 로 출력하기

  13. No Image 26Mar
    by
    2014/03/26 Views 19805 

    웹페이지 프린트 하기 html 수준

  14. No Image 26Mar
    by
    2014/03/26 Views 20551 

    [PHP] 한글명 파일 다운로드받기

  15. No Image 27Feb
    by
    2014/02/27 Views 21075 

    FPDF - PHP로 PDF 만들기

  16. No Image 27Feb
    by
    2014/02/27 Views 26351 

    해당하는 날짜가 그달의 몇주째인지 계산

  17. No Image 27Feb
    by 조쉬
    2014/02/27 Views 19794 

    php 파일 다운로드 구현

  18. No Image 27Feb
    by
    2014/02/27 Views 20234 

    php 파일 확장자

  19. No Image 27Feb
    by
    2014/02/27 Views 19729 

    MYSQL 업데이트 두 번 하기

  20. No Image 27Feb
    by
    2014/02/27 Views 20349 

    mysql 에러 구문 표시

Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved