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

· 10년 전 · 498

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


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년 전 조회 540
10년 전 조회 591
10년 전 조회 547
10년 전 조회 606
10년 전 조회 609
10년 전 조회 591
10년 전 조회 749
10년 전 조회 762
10년 전 조회 526
10년 전 조회 828
10년 전 조회 1,182
10년 전 조회 632
10년 전 조회 867
10년 전 조회 861
10년 전 조회 695
10년 전 조회 629
10년 전 조회 613
10년 전 조회 714
10년 전 조회 486
10년 전 조회 521
10년 전 조회 739
10년 전 조회 567
10년 전 조회 531
10년 전 조회 515
10년 전 조회 523
10년 전 조회 535
10년 전 조회 513
10년 전 조회 531
10년 전 조회 552
10년 전 조회 647
10년 전 조회 481
10년 전 조회 505
10년 전 조회 593
10년 전 조회 1,341
10년 전 조회 545
10년 전 조회 541
10년 전 조회 668
10년 전 조회 555
10년 전 조회 740
10년 전 조회 653
10년 전 조회 541
10년 전 조회 544
10년 전 조회 598
10년 전 조회 587
10년 전 조회 484
10년 전 조회 481
10년 전 조회 449
10년 전 조회 492
10년 전 조회 886
10년 전 조회 499
10년 전 조회 614
10년 전 조회 530
10년 전 조회 733
10년 전 조회 538
10년 전 조회 463
10년 전 조회 510
10년 전 조회 525
10년 전 조회 662
10년 전 조회 594
10년 전 조회 443
10년 전 조회 515
10년 전 조회 1,462
10년 전 조회 1,367
10년 전 조회 894
10년 전 조회 1,508
10년 전 조회 557
10년 전 조회 994
10년 전 조회 1,213
10년 전 조회 661
10년 전 조회 611
10년 전 조회 608
10년 전 조회 459
10년 전 조회 625
10년 전 조회 629
10년 전 조회 1,156
10년 전 조회 573
10년 전 조회 641
10년 전 조회 619
10년 전 조회 1,538
10년 전 조회 654
10년 전 조회 515
10년 전 조회 663
10년 전 조회 672
10년 전 조회 755
10년 전 조회 544
10년 전 조회 610
10년 전 조회 1,007
10년 전 조회 937
10년 전 조회 913
10년 전 조회 467
10년 전 조회 563
10년 전 조회 563
10년 전 조회 501
10년 전 조회 756
10년 전 조회 494
10년 전 조회 825
10년 전 조회 492
10년 전 조회 784
10년 전 조회 492
10년 전 조회 720
🐛 버그신고