메뉴 건너뛰기

프로그램언어

조회 수 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 06Mar
    by
    2017/03/06 Views 21695 

    PHPExcel 클래스를 이용해 Excel 2007~2010 의 xlsx 파일 읽기 (100만 행 까지)

  2. No Image 08Jan
    by
    2019/01/08 Views 1429 

    php/asp에서 가상번호 부여와 가상번호를 거꾸로 적용

  3. No Image 13Apr
    by
    2017/04/13 Views 19505 

    PHP, $_SERVER 변수

  4. No Image 04Jul
    by
    2018/07/04 Views 4057 

    PHP 휴대폰번호 짜르기 (preg_replace) "-" 넣기. 형식바꾸기

  5. No Image 27Oct
    by
    2018/10/27 Views 3790 

    PHP 확장 모듈을 이용한 C 라이브러리 사용

  6. No Image 12Jan
    by
    2023/01/12 Views 236 

    PHP 하위 디렉토리 포함 디렉토리 리스트 출력

  7. No Image 04Jul
    by
    2018/07/04 Views 5811 

    PHP 파일크기 단위 붙이기 (용량 변환) file size conversion source code

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

    php 파일 확장자

  9. No Image 12Jan
    by
    2023/01/12 Views 229 

    PHP 파일 업로드 FORM 처리

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

    php 파일 다운로드 구현

  11. No Image 12Apr
    by
    2014/04/12 Views 21704 

    php 파일 다운로드 구현

  12. No Image 14Apr
    by
    2015/04/14 Views 22401 

    PHP 파일 다루기

  13. No Image 19Jul
    by
    2018/07/19 Views 5455 

    PHP 특정 디렉토리에 있는 파일 갯수 구하기

  14. No Image 12Jan
    by
    2023/01/12 Views 259 

    php 이미지 리사이징 image resizing

  15. No Image 12Jan
    by
    2023/01/12 Views 212 

    PHP 이미지 리사이즈 함수 imagecopyresized

  16. No Image 24Jun
    by
    2019/06/24 Views 1946 

    PHP 외부 XML 파싱 하기

  17. No Image 07Mar
    by
    2017/03/07 Views 29790 

    php 엑셀 다운로드 구현

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

    PHP 에서의 소켓(Socket) 통신

  19. No Image 12Jan
    by
    2023/01/12 Views 367 

    php 암호화 복호화 , 간단한 암호화

  20. No Image 26Mar
    by
    2021/03/26 Views 832 

    PHP 쉘 스크립트

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

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved