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

· 10년 전 · 494

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


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년 전 조회 539
10년 전 조회 585
10년 전 조회 542
10년 전 조회 602
10년 전 조회 603
10년 전 조회 588
10년 전 조회 747
10년 전 조회 757
10년 전 조회 521
10년 전 조회 824
10년 전 조회 1,179
10년 전 조회 630
10년 전 조회 859
10년 전 조회 857
10년 전 조회 692
10년 전 조회 624
10년 전 조회 611
10년 전 조회 709
10년 전 조회 482
10년 전 조회 516
10년 전 조회 735
10년 전 조회 562
10년 전 조회 527
10년 전 조회 510
10년 전 조회 520
10년 전 조회 531
10년 전 조회 509
10년 전 조회 526
10년 전 조회 548
10년 전 조회 643
10년 전 조회 480
10년 전 조회 502
10년 전 조회 588
10년 전 조회 1,337
10년 전 조회 542
10년 전 조회 536
10년 전 조회 667
10년 전 조회 552
10년 전 조회 736
10년 전 조회 651
10년 전 조회 541
10년 전 조회 539
10년 전 조회 595
10년 전 조회 586
10년 전 조회 479
10년 전 조회 480
10년 전 조회 443
10년 전 조회 489
10년 전 조회 883
10년 전 조회 495
10년 전 조회 613
10년 전 조회 525
10년 전 조회 729
10년 전 조회 531
10년 전 조회 460
10년 전 조회 507
10년 전 조회 523
10년 전 조회 660
10년 전 조회 590
10년 전 조회 440
10년 전 조회 512
10년 전 조회 1,457
10년 전 조회 1,367
10년 전 조회 891
10년 전 조회 1,507
10년 전 조회 554
10년 전 조회 989
10년 전 조회 1,211
10년 전 조회 656
10년 전 조회 610
10년 전 조회 602
10년 전 조회 458
10년 전 조회 624
10년 전 조회 626
10년 전 조회 1,155
10년 전 조회 570
10년 전 조회 638
10년 전 조회 618
10년 전 조회 1,536
10년 전 조회 651
10년 전 조회 511
10년 전 조회 655
10년 전 조회 669
10년 전 조회 751
10년 전 조회 541
10년 전 조회 606
10년 전 조회 1,003
10년 전 조회 934
10년 전 조회 912
10년 전 조회 466
10년 전 조회 558
10년 전 조회 560
10년 전 조회 500
10년 전 조회 753
10년 전 조회 489
10년 전 조회 822
10년 전 조회 483
10년 전 조회 780
10년 전 조회 488
10년 전 조회 717
🐛 버그신고