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

· 10년 전 · 1430

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


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,411
10년 전 조회 1,458
10년 전 조회 1,451
10년 전 조회 1,479
10년 전 조회 1,516
10년 전 조회 1,484
10년 전 조회 1,634
10년 전 조회 1,621
10년 전 조회 1,416
10년 전 조회 1,731
10년 전 조회 2,053
10년 전 조회 1,522
10년 전 조회 1,767
10년 전 조회 1,729
10년 전 조회 1,577
10년 전 조회 1,556
10년 전 조회 1,510
10년 전 조회 1,617
10년 전 조회 1,357
10년 전 조회 1,433
10년 전 조회 1,659
10년 전 조회 1,482
10년 전 조회 1,455
10년 전 조회 1,425
10년 전 조회 1,450
10년 전 조회 1,469
10년 전 조회 1,458
10년 전 조회 1,480
10년 전 조회 1,426
10년 전 조회 1,600
10년 전 조회 1,429
10년 전 조회 1,432
10년 전 조회 1,540
10년 전 조회 2,250
10년 전 조회 1,502
10년 전 조회 1,466
10년 전 조회 1,556
10년 전 조회 1,472
10년 전 조회 1,653
10년 전 조회 1,555
10년 전 조회 1,472
10년 전 조회 1,471
10년 전 조회 1,498
10년 전 조회 1,493
10년 전 조회 1,428
10년 전 조회 1,381
10년 전 조회 1,361
10년 전 조회 1,402
10년 전 조회 1,791
10년 전 조회 1,431
10년 전 조회 1,522
10년 전 조회 1,467
10년 전 조회 1,706
10년 전 조회 1,522
10년 전 조회 1,446
10년 전 조회 1,471
10년 전 조회 1,504
10년 전 조회 1,627
10년 전 조회 1,547
10년 전 조회 1,449
10년 전 조회 1,488
10년 전 조회 2,439
10년 전 조회 2,300
10년 전 조회 1,866
10년 전 조회 2,438
10년 전 조회 1,513
10년 전 조회 1,911
10년 전 조회 2,149
10년 전 조회 1,643
10년 전 조회 1,582
10년 전 조회 1,558
10년 전 조회 1,418
10년 전 조회 1,598
10년 전 조회 1,590
10년 전 조회 2,114
10년 전 조회 1,526
10년 전 조회 1,598
10년 전 조회 1,599
10년 전 조회 2,523
10년 전 조회 1,652
10년 전 조회 1,538
10년 전 조회 1,625
10년 전 조회 1,661
10년 전 조회 1,737
10년 전 조회 1,537
10년 전 조회 1,609
10년 전 조회 1,956
10년 전 조회 1,908
10년 전 조회 1,885
10년 전 조회 1,439
10년 전 조회 1,542
10년 전 조회 1,494
10년 전 조회 1,455
10년 전 조회 1,679
10년 전 조회 1,444
10년 전 조회 1,746
10년 전 조회 1,437
10년 전 조회 1,773
10년 전 조회 1,463
10년 전 조회 1,694