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

· 10년 전 · 572

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


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년 전 조회 650
10년 전 조회 684
10년 전 조회 634
10년 전 조회 711
10년 전 조회 701
10년 전 조회 695
10년 전 조회 840
10년 전 조회 841
10년 전 조회 616
10년 전 조회 915
10년 전 조회 1,276
10년 전 조회 726
10년 전 조회 963
10년 전 조회 936
10년 전 조회 796
10년 전 조회 727
10년 전 조회 705
10년 전 조회 798
10년 전 조회 583
10년 전 조회 612
10년 전 조회 835
10년 전 조회 667
10년 전 조회 624
10년 전 조회 600
10년 전 조회 617
10년 전 조회 631
10년 전 조회 613
10년 전 조회 619
10년 전 조회 642
10년 전 조회 744
10년 전 조회 574
10년 전 조회 600
10년 전 조회 681
10년 전 조회 1,421
10년 전 조회 634
10년 전 조회 635
10년 전 조회 746
10년 전 조회 640
10년 전 조회 816
10년 전 조회 728
10년 전 조회 631
10년 전 조회 634
10년 전 조회 697
10년 전 조회 676
10년 전 조회 583
10년 전 조회 570
10년 전 조회 531
10년 전 조회 579
10년 전 조회 977
10년 전 조회 573
10년 전 조회 713
10년 전 조회 609
10년 전 조회 815
10년 전 조회 635
10년 전 조회 530
10년 전 조회 591
10년 전 조회 627
10년 전 조회 745
10년 전 조회 684
10년 전 조회 532
10년 전 조회 606
10년 전 조회 1,558
10년 전 조회 1,448
10년 전 조회 993
10년 전 조회 1,605
10년 전 조회 646
10년 전 조회 1,088
10년 전 조회 1,301
10년 전 조회 754
10년 전 조회 696
10년 전 조회 687
10년 전 조회 548
10년 전 조회 719
10년 전 조회 708
10년 전 조회 1,250
10년 전 조회 656
10년 전 조회 733
10년 전 조회 705
10년 전 조회 1,629
10년 전 조회 747
10년 전 조회 626
10년 전 조회 751
10년 전 조회 759
10년 전 조회 845
10년 전 조회 624
10년 전 조회 713
10년 전 조회 1,079
10년 전 조회 1,019
10년 전 조회 1,001
10년 전 조회 553
10년 전 조회 656
10년 전 조회 651
10년 전 조회 585
10년 전 조회 824
10년 전 조회 589
10년 전 조회 906
10년 전 조회 573
10년 전 조회 897
10년 전 조회 575
10년 전 조회 817