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

· 10년 전 · 1228

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


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,246
10년 전 조회 1,279
10년 전 조회 1,276
10년 전 조회 1,307
10년 전 조회 1,332
10년 전 조회 1,303
10년 전 조회 1,452
10년 전 조회 1,449
10년 전 조회 1,236
10년 전 조회 1,543
10년 전 조회 1,903
10년 전 조회 1,339
10년 전 조회 1,591
10년 전 조회 1,550
10년 전 조회 1,396
10년 전 조회 1,367
10년 전 조회 1,321
10년 전 조회 1,435
10년 전 조회 1,176
10년 전 조회 1,256
10년 전 조회 1,466
10년 전 조회 1,291
10년 전 조회 1,290
10년 전 조회 1,250
10년 전 조회 1,278
10년 전 조회 1,258
10년 전 조회 1,249
10년 전 조회 1,279
10년 전 조회 1,250
10년 전 조회 1,410
10년 전 조회 1,236
10년 전 조회 1,237
10년 전 조회 1,315
10년 전 조회 2,055
10년 전 조회 1,288
10년 전 조회 1,280
10년 전 조회 1,376
10년 전 조회 1,277
10년 전 조회 1,430
10년 전 조회 1,364
10년 전 조회 1,277
10년 전 조회 1,285
10년 전 조회 1,329
10년 전 조회 1,310
10년 전 조회 1,230
10년 전 조회 1,185
10년 전 조회 1,158
10년 전 조회 1,193
10년 전 조회 1,584
10년 전 조회 1,229
10년 전 조회 1,332
10년 전 조회 1,290
10년 전 조회 1,499
10년 전 조회 1,321
10년 전 조회 1,256
10년 전 조회 1,268
10년 전 조회 1,305
10년 전 조회 1,428
10년 전 조회 1,356
10년 전 조회 1,261
10년 전 조회 1,295
10년 전 조회 2,228
10년 전 조회 2,103
10년 전 조회 1,670
10년 전 조회 2,236
10년 전 조회 1,283
10년 전 조회 1,736
10년 전 조회 1,956
10년 전 조회 1,430
10년 전 조회 1,410
10년 전 조회 1,369
10년 전 조회 1,236
10년 전 조회 1,410
10년 전 조회 1,404
10년 전 조회 1,919
10년 전 조회 1,345
10년 전 조회 1,390
10년 전 조회 1,427
10년 전 조회 2,311
10년 전 조회 1,469
10년 전 조회 1,351
10년 전 조회 1,430
10년 전 조회 1,479
10년 전 조회 1,556
10년 전 조회 1,362
10년 전 조회 1,419
10년 전 조회 1,761
10년 전 조회 1,713
10년 전 조회 1,683
10년 전 조회 1,233
10년 전 조회 1,365
10년 전 조회 1,320
10년 전 조회 1,257
10년 전 조회 1,489
10년 전 조회 1,262
10년 전 조회 1,562
10년 전 조회 1,245
10년 전 조회 1,553
10년 전 조회 1,249
10년 전 조회 1,512