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

· 10년 전 · 994

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


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,055
10년 전 조회 1,107
10년 전 조회 1,079
10년 전 조회 1,152
10년 전 조회 1,140
10년 전 조회 1,112
10년 전 조회 1,257
10년 전 조회 1,247
10년 전 조회 1,033
10년 전 조회 1,343
10년 전 조회 1,700
10년 전 조회 1,145
10년 전 조회 1,392
10년 전 조회 1,349
10년 전 조회 1,208
10년 전 조회 1,160
10년 전 조회 1,116
10년 전 조회 1,242
10년 전 조회 992
10년 전 조회 1,054
10년 전 조회 1,272
10년 전 조회 1,100
10년 전 조회 1,065
10년 전 조회 1,048
10년 전 조회 1,048
10년 전 조회 1,043
10년 전 조회 1,042
10년 전 조회 1,063
10년 전 조회 1,064
10년 전 조회 1,173
10년 전 조회 1,021
10년 전 조회 1,019
10년 전 조회 1,101
10년 전 조회 1,827
10년 전 조회 1,034
10년 전 조회 1,059
10년 전 조회 1,171
10년 전 조회 1,089
10년 전 조회 1,214
10년 전 조회 1,164
10년 전 조회 1,059
10년 전 조회 1,048
10년 전 조회 1,116
10년 전 조회 1,077
10년 전 조회 1,021
10년 전 조회 985
10년 전 조회 943
10년 전 조회 980
10년 전 조회 1,382
10년 전 조회 995
10년 전 조회 1,115
10년 전 조회 1,059
10년 전 조회 1,257
10년 전 조회 1,098
10년 전 조회 988
10년 전 조회 1,039
10년 전 조회 1,056
10년 전 조회 1,182
10년 전 조회 1,132
10년 전 조회 992
10년 전 조회 1,047
10년 전 조회 1,985
10년 전 조회 1,853
10년 전 조회 1,416
10년 전 조회 1,996
10년 전 조회 1,058
10년 전 조회 1,515
10년 전 조회 1,728
10년 전 조회 1,263
10년 전 조회 1,240
10년 전 조회 1,144
10년 전 조회 990
10년 전 조회 1,184
10년 전 조회 1,160
10년 전 조회 1,699
10년 전 조회 1,113
10년 전 조회 1,159
10년 전 조회 1,169
10년 전 조회 2,075
10년 전 조회 1,205
10년 전 조회 1,092
10년 전 조회 1,189
10년 전 조회 1,230
10년 전 조회 1,319
10년 전 조회 1,109
10년 전 조회 1,182
10년 전 조회 1,512
10년 전 조회 1,473
10년 전 조회 1,459
10년 전 조회 1,004
10년 전 조회 1,106
10년 전 조회 1,084
10년 전 조회 1,019
10년 전 조회 1,255
10년 전 조회 1,022
10년 전 조회 1,344
10년 전 조회 1,002
10년 전 조회 1,319
10년 전 조회 1,028
10년 전 조회 1,266