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

· 10년 전 · 1588

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


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년 전 조회 1,607
10년 전 조회 1,652
10년 전 조회 1,627
10년 전 조회 1,689
10년 전 조회 1,697
10년 전 조회 1,685
10년 전 조회 1,836
10년 전 조회 1,838
10년 전 조회 1,632
10년 전 조회 1,930
10년 전 조회 2,243
10년 전 조회 1,715
10년 전 조회 1,976
10년 전 조회 1,932
10년 전 조회 1,783
10년 전 조회 1,761
10년 전 조회 1,702
10년 전 조회 1,809
10년 전 조회 1,565
10년 전 조회 1,646
10년 전 조회 1,859
10년 전 조회 1,678
10년 전 조회 1,629
10년 전 조회 1,632
10년 전 조회 1,647
10년 전 조회 1,675
10년 전 조회 1,654
10년 전 조회 1,668
10년 전 조회 1,629
10년 전 조회 1,798
10년 전 조회 1,607
10년 전 조회 1,630
10년 전 조회 1,736
10년 전 조회 2,417
10년 전 조회 1,684
10년 전 조회 1,656
10년 전 조회 1,740
10년 전 조회 1,636
10년 전 조회 1,818
10년 전 조회 1,729
10년 전 조회 1,653
10년 전 조회 1,640
10년 전 조회 1,669
10년 전 조회 1,673
10년 전 조회 1,599
10년 전 조회 1,547
10년 전 조회 1,535
10년 전 조회 1,563
10년 전 조회 1,986
10년 전 조회 1,589
10년 전 조회 1,705
10년 전 조회 1,633
10년 전 조회 1,879
10년 전 조회 1,700
10년 전 조회 1,597
10년 전 조회 1,644
10년 전 조회 1,686
10년 전 조회 1,790
10년 전 조회 1,740
10년 전 조회 1,623
10년 전 조회 1,656
10년 전 조회 2,617
10년 전 조회 2,498
10년 전 조회 2,045
10년 전 조회 2,621
10년 전 조회 1,679
10년 전 조회 2,084
10년 전 조회 2,325
10년 전 조회 1,837
10년 전 조회 1,764
10년 전 조회 1,728
10년 전 조회 1,596
10년 전 조회 1,774
10년 전 조회 1,778
10년 전 조회 2,289
10년 전 조회 1,694
10년 전 조회 1,798
10년 전 조회 1,761
10년 전 조회 2,697
10년 전 조회 1,823
10년 전 조회 1,706
10년 전 조회 1,799
10년 전 조회 1,820
10년 전 조회 1,896
10년 전 조회 1,698
10년 전 조회 1,787
10년 전 조회 2,122
10년 전 조회 2,064
10년 전 조회 2,036
10년 전 조회 1,600
10년 전 조회 1,698
10년 전 조회 1,652
10년 전 조회 1,612
10년 전 조회 1,821
10년 전 조회 1,614
10년 전 조회 1,915
10년 전 조회 1,593
10년 전 조회 1,926
10년 전 조회 1,629
10년 전 조회 1,856