파일이름의 확장자로 파일 종류를 확인하는 함수 입니다.

· 10년 전 · 508

파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.


function file_type($filename)
{
      $tmp = explode(".", $filename);
      $ext = trim($tmp[count($tmp)-1]);

      $type_image = "jpg|jpeg|gif|bmp|pcx|png";
      $type_compress = "zip|alz|gz|tar|z|rar|ace|bz|bz2";
      $type_text = "txt|text|rtf|2b";
      $type_html = "htm|html";
      $type_hwp = "hwp|h30";
      $type_exe = "exe";
      $type_font = "ttf";
      $type_movie = "avi|mpg|mpeg|mqv|asf|wmv|mov";
      $type_sound = "wav|mp3|mid|wma";

      if(preg_match("/($type_image)/i",$ext))
              $file_type = 'image';
      else if(preg_match("/($type_compress)/i",$ext))
              $file_type = 'compress';
      else if(preg_match("/($type_text)/i",$ext))
              $file_type = 'text';
      else if(preg_match("/($type_html)/i",$ext))
              $file_type = 'html';
      else if(preg_match("/($type_hwp)/i",$ext))
              $file_type = 'hwp';
      else if(preg_match("/($type_exe)/i",$ext))
              $file_type = 'exe';
      else if(preg_match("/($type_font)/i",$ext))
              $file_type = 'font';
      else if(preg_match("/($type_movie)/i",$ext))
              $file_type = 'movie';
      else if(preg_match("/($type_sound)/i",$ext))
              $file_type = 'sound';
      else
              $file_type = 'unknown';

      return $file_type;
}  

|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
10년 전 조회 563
10년 전 조회 610
10년 전 조회 568
10년 전 조회 634
10년 전 조회 634
10년 전 조회 608
10년 전 조회 772
10년 전 조회 780
10년 전 조회 548
10년 전 조회 848
10년 전 조회 1,197
10년 전 조회 656
10년 전 조회 888
10년 전 조회 879
10년 전 조회 720
10년 전 조회 655
10년 전 조회 631
10년 전 조회 736
10년 전 조회 505
10년 전 조회 534
10년 전 조회 754
10년 전 조회 593
10년 전 조회 546
10년 전 조회 526
10년 전 조회 543
10년 전 조회 560
10년 전 조회 537
10년 전 조회 553
10년 전 조회 570
10년 전 조회 669
10년 전 조회 501
10년 전 조회 534
10년 전 조회 614
10년 전 조회 1,351
10년 전 조회 563
10년 전 조회 557
10년 전 조회 682
10년 전 조회 573
10년 전 조회 752
10년 전 조회 666
10년 전 조회 557
10년 전 조회 562
10년 전 조회 615
10년 전 조회 602
10년 전 조회 502
10년 전 조회 494
10년 전 조회 463
10년 전 조회 504
10년 전 조회 904
10년 전 조회 509
10년 전 조회 630
10년 전 조회 538
10년 전 조회 748
10년 전 조회 562
10년 전 조회 474
10년 전 조회 527
10년 전 조회 547
10년 전 조회 682
10년 전 조회 614
10년 전 조회 457
10년 전 조회 533
10년 전 조회 1,486
10년 전 조회 1,377
10년 전 조회 919
10년 전 조회 1,528
10년 전 조회 570
10년 전 조회 1,021
10년 전 조회 1,226
10년 전 조회 680
10년 전 조회 622
10년 전 조회 618
10년 전 조회 468
10년 전 조회 647
10년 전 조회 643
10년 전 조회 1,177
10년 전 조회 591
10년 전 조회 663
10년 전 조회 639
10년 전 조회 1,559
10년 전 조회 664
10년 전 조회 521
10년 전 조회 678
10년 전 조회 683
10년 전 조회 769
10년 전 조회 555
10년 전 조회 631
10년 전 조회 1,014
10년 전 조회 954
10년 전 조회 930
10년 전 조회 478
10년 전 조회 577
10년 전 조회 579
10년 전 조회 514
10년 전 조회 762
10년 전 조회 519
10년 전 조회 836
10년 전 조회 501
10년 전 조회 814
10년 전 조회 506
10년 전 조회 737
🐛 버그신고