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

· 10년 전 · 1542

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


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,559
10년 전 조회 1,605
10년 전 조회 1,584
10년 전 조회 1,626
10년 전 조회 1,648
10년 전 조회 1,627
10년 전 조회 1,780
10년 전 조회 1,771
10년 전 조회 1,574
10년 전 조회 1,869
10년 전 조회 2,204
10년 전 조회 1,656
10년 전 조회 1,925
10년 전 조회 1,889
10년 전 조회 1,735
10년 전 조회 1,709
10년 전 조회 1,651
10년 전 조회 1,753
10년 전 조회 1,505
10년 전 조회 1,593
10년 전 조회 1,810
10년 전 조회 1,631
10년 전 조회 1,574
10년 전 조회 1,584
10년 전 조회 1,587
10년 전 조회 1,614
10년 전 조회 1,606
10년 전 조회 1,620
10년 전 조회 1,573
10년 전 조회 1,754
10년 전 조회 1,554
10년 전 조회 1,577
10년 전 조회 1,689
10년 전 조회 2,366
10년 전 조회 1,635
10년 전 조회 1,618
10년 전 조회 1,684
10년 전 조회 1,594
10년 전 조회 1,775
10년 전 조회 1,684
10년 전 조회 1,602
10년 전 조회 1,587
10년 전 조회 1,623
10년 전 조회 1,631
10년 전 조회 1,557
10년 전 조회 1,507
10년 전 조회 1,489
10년 전 조회 1,519
10년 전 조회 1,937
10년 전 조회 1,543
10년 전 조회 1,660
10년 전 조회 1,591
10년 전 조회 1,827
10년 전 조회 1,650
10년 전 조회 1,562
10년 전 조회 1,599
10년 전 조회 1,626
10년 전 조회 1,745
10년 전 조회 1,688
10년 전 조회 1,575
10년 전 조회 1,609
10년 전 조회 2,570
10년 전 조회 2,443
10년 전 조회 1,991
10년 전 조회 2,572
10년 전 조회 1,637
10년 전 조회 2,038
10년 전 조회 2,278
10년 전 조회 1,781
10년 전 조회 1,713
10년 전 조회 1,686
10년 전 조회 1,554
10년 전 조회 1,720
10년 전 조회 1,729
10년 전 조회 2,240
10년 전 조회 1,656
10년 전 조회 1,749
10년 전 조회 1,729
10년 전 조회 2,638
10년 전 조회 1,787
10년 전 조회 1,659
10년 전 조회 1,753
10년 전 조회 1,771
10년 전 조회 1,850
10년 전 조회 1,656
10년 전 조회 1,744
10년 전 조회 2,079
10년 전 조회 2,020
10년 전 조회 1,993
10년 전 조회 1,550
10년 전 조회 1,646
10년 전 조회 1,609
10년 전 조회 1,570
10년 전 조회 1,787
10년 전 조회 1,562
10년 전 조회 1,873
10년 전 조회 1,554
10년 전 조회 1,883
10년 전 조회 1,581
10년 전 조회 1,811