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

· 10년 전 · 1244

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


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,252
10년 전 조회 1,288
10년 전 조회 1,281
10년 전 조회 1,312
10년 전 조회 1,343
10년 전 조회 1,306
10년 전 조회 1,467
10년 전 조회 1,461
10년 전 조회 1,242
10년 전 조회 1,549
10년 전 조회 1,904
10년 전 조회 1,342
10년 전 조회 1,601
10년 전 조회 1,559
10년 전 조회 1,407
10년 전 조회 1,373
10년 전 조회 1,332
10년 전 조회 1,442
10년 전 조회 1,184
10년 전 조회 1,263
10년 전 조회 1,481
10년 전 조회 1,298
10년 전 조회 1,298
10년 전 조회 1,258
10년 전 조회 1,289
10년 전 조회 1,269
10년 전 조회 1,261
10년 전 조회 1,287
10년 전 조회 1,257
10년 전 조회 1,421
10년 전 조회 1,241
10년 전 조회 1,243
10년 전 조회 1,322
10년 전 조회 2,069
10년 전 조회 1,293
10년 전 조회 1,290
10년 전 조회 1,382
10년 전 조회 1,288
10년 전 조회 1,442
10년 전 조회 1,374
10년 전 조회 1,292
10년 전 조회 1,292
10년 전 조회 1,342
10년 전 조회 1,318
10년 전 조회 1,241
10년 전 조회 1,199
10년 전 조회 1,170
10년 전 조회 1,201
10년 전 조회 1,590
10년 전 조회 1,245
10년 전 조회 1,344
10년 전 조회 1,297
10년 전 조회 1,513
10년 전 조회 1,329
10년 전 조회 1,272
10년 전 조회 1,278
10년 전 조회 1,313
10년 전 조회 1,434
10년 전 조회 1,366
10년 전 조회 1,269
10년 전 조회 1,305
10년 전 조회 2,237
10년 전 조회 2,108
10년 전 조회 1,681
10년 전 조회 2,247
10년 전 조회 1,296
10년 전 조회 1,744
10년 전 조회 1,965
10년 전 조회 1,439
10년 전 조회 1,418
10년 전 조회 1,378
10년 전 조회 1,243
10년 전 조회 1,420
10년 전 조회 1,411
10년 전 조회 1,926
10년 전 조회 1,354
10년 전 조회 1,406
10년 전 조회 1,436
10년 전 조회 2,324
10년 전 조회 1,475
10년 전 조회 1,361
10년 전 조회 1,440
10년 전 조회 1,489
10년 전 조회 1,563
10년 전 조회 1,369
10년 전 조회 1,427
10년 전 조회 1,765
10년 전 조회 1,720
10년 전 조회 1,690
10년 전 조회 1,244
10년 전 조회 1,372
10년 전 조회 1,325
10년 전 조회 1,261
10년 전 조회 1,495
10년 전 조회 1,272
10년 전 조회 1,570
10년 전 조회 1,258
10년 전 조회 1,568
10년 전 조회 1,258
10년 전 조회 1,517