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

· 10년 전 · 946

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


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,018
10년 전 조회 1,073
10년 전 조회 1,046
10년 전 조회 1,111
10년 전 조회 1,097
10년 전 조회 1,080
10년 전 조회 1,221
10년 전 조회 1,207
10년 전 조회 1,001
10년 전 조회 1,308
10년 전 조회 1,650
10년 전 조회 1,106
10년 전 조회 1,353
10년 전 조회 1,316
10년 전 조회 1,172
10년 전 조회 1,128
10년 전 조회 1,085
10년 전 조회 1,201
10년 전 조회 962
10년 전 조회 1,022
10년 전 조회 1,237
10년 전 조회 1,063
10년 전 조회 1,024
10년 전 조회 1,014
10년 전 조회 1,007
10년 전 조회 1,011
10년 전 조회 1,003
10년 전 조회 1,027
10년 전 조회 1,024
10년 전 조회 1,131
10년 전 조회 980
10년 전 조회 983
10년 전 조회 1,062
10년 전 조회 1,786
10년 전 조회 997
10년 전 조회 1,020
10년 전 조회 1,130
10년 전 조회 1,056
10년 전 조회 1,170
10년 전 조회 1,136
10년 전 조회 1,018
10년 전 조회 1,013
10년 전 조회 1,082
10년 전 조회 1,044
10년 전 조회 981
10년 전 조회 940
10년 전 조회 907
10년 전 조회 946
10년 전 조회 1,341
10년 전 조회 947
10년 전 조회 1,080
10년 전 조회 1,003
10년 전 조회 1,204
10년 전 조회 1,030
10년 전 조회 919
10년 전 조회 971
10년 전 조회 1,004
10년 전 조회 1,123
10년 전 조회 1,057
10년 전 조회 930
10년 전 조회 983
10년 전 조회 1,933
10년 전 조회 1,800
10년 전 조회 1,362
10년 전 조회 1,950
10년 전 조회 998
10년 전 조회 1,451
10년 전 조회 1,658
10년 전 조회 1,224
10년 전 조회 1,192
10년 전 조회 1,089
10년 전 조회 933
10년 전 조회 1,121
10년 전 조회 1,100
10년 전 조회 1,643
10년 전 조회 1,042
10년 전 조회 1,106
10년 전 조회 1,112
10년 전 조회 2,014
10년 전 조회 1,138
10년 전 조회 1,020
10년 전 조회 1,129
10년 전 조회 1,159
10년 전 조회 1,263
10년 전 조회 1,036
10년 전 조회 1,109
10년 전 조회 1,457
10년 전 조회 1,407
10년 전 조회 1,398
10년 전 조회 936
10년 전 조회 1,044
10년 전 조회 1,023
10년 전 조회 967
10년 전 조회 1,187
10년 전 조회 960
10년 전 조회 1,291
10년 전 조회 948
10년 전 조회 1,263
10년 전 조회 955
10년 전 조회 1,205