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

· 10년 전 · 1179

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


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,210
10년 전 조회 1,254
10년 전 조회 1,249
10년 전 조회 1,290
10년 전 조회 1,297
10년 전 조회 1,272
10년 전 조회 1,426
10년 전 조회 1,420
10년 전 조회 1,210
10년 전 조회 1,511
10년 전 조회 1,872
10년 전 조회 1,304
10년 전 조회 1,554
10년 전 조회 1,517
10년 전 조회 1,369
10년 전 조회 1,331
10년 전 조회 1,291
10년 전 조회 1,400
10년 전 조회 1,149
10년 전 조회 1,217
10년 전 조회 1,437
10년 전 조회 1,253
10년 전 조회 1,242
10년 전 조회 1,217
10년 전 조회 1,235
10년 전 조회 1,207
10년 전 조회 1,211
10년 전 조회 1,242
10년 전 조회 1,226
10년 전 조회 1,364
10년 전 조회 1,190
10년 전 조회 1,189
10년 전 조회 1,274
10년 전 조회 2,012
10년 전 조회 1,245
10년 전 조회 1,241
10년 전 조회 1,338
10년 전 조회 1,240
10년 전 조회 1,388
10년 전 조회 1,327
10년 전 조회 1,231
10년 전 조회 1,238
10년 전 조회 1,289
10년 전 조회 1,270
10년 전 조회 1,192
10년 전 조회 1,148
10년 전 조회 1,116
10년 전 조회 1,154
10년 전 조회 1,552
10년 전 조회 1,180
10년 전 조회 1,291
10년 전 조회 1,246
10년 전 조회 1,460
10년 전 조회 1,289
10년 전 조회 1,219
10년 전 조회 1,239
10년 전 조회 1,268
10년 전 조회 1,392
10년 전 조회 1,318
10년 전 조회 1,209
10년 전 조회 1,263
10년 전 조회 2,187
10년 전 조회 2,074
10년 전 조회 1,635
10년 전 조회 2,211
10년 전 조회 1,243
10년 전 조회 1,710
10년 전 조회 1,929
10년 전 조회 1,398
10년 전 조회 1,380
10년 전 조회 1,337
10년 전 조회 1,192
10년 전 조회 1,382
10년 전 조회 1,369
10년 전 조회 1,888
10년 전 조회 1,305
10년 전 조회 1,366
10년 전 조회 1,387
10년 전 조회 2,281
10년 전 조회 1,435
10년 전 조회 1,322
10년 전 조회 1,391
10년 전 조회 1,443
10년 전 조회 1,514
10년 전 조회 1,324
10년 전 조회 1,384
10년 전 조회 1,728
10년 전 조회 1,678
10년 전 조회 1,652
10년 전 조회 1,200
10년 전 조회 1,324
10년 전 조회 1,275
10년 전 조회 1,226
10년 전 조회 1,461
10년 전 조회 1,218
10년 전 조회 1,534
10년 전 조회 1,212
10년 전 조회 1,510
10년 전 조회 1,210
10년 전 조회 1,479