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

· 10년 전 · 495

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


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년 전 조회 587
10년 전 조회 544
10년 전 조회 603
10년 전 조회 604
10년 전 조회 589
10년 전 조회 747
10년 전 조회 759
10년 전 조회 523
10년 전 조회 825
10년 전 조회 1,180
10년 전 조회 630
10년 전 조회 859
10년 전 조회 858
10년 전 조회 692
10년 전 조회 624
10년 전 조회 612
10년 전 조회 710
10년 전 조회 482
10년 전 조회 517
10년 전 조회 735
10년 전 조회 564
10년 전 조회 527
10년 전 조회 511
10년 전 조회 520
10년 전 조회 531
10년 전 조회 510
10년 전 조회 526
10년 전 조회 548
10년 전 조회 644
10년 전 조회 481
10년 전 조회 504
10년 전 조회 588
10년 전 조회 1,339
10년 전 조회 543
10년 전 조회 537
10년 전 조회 667
10년 전 조회 552
10년 전 조회 736
10년 전 조회 651
10년 전 조회 541
10년 전 조회 540
10년 전 조회 595
10년 전 조회 586
10년 전 조회 480
10년 전 조회 481
10년 전 조회 446
10년 전 조회 489
10년 전 조회 884
10년 전 조회 496
10년 전 조회 613
10년 전 조회 528
10년 전 조회 729
10년 전 조회 534
10년 전 조회 461
10년 전 조회 507
10년 전 조회 523
10년 전 조회 660
10년 전 조회 591
10년 전 조회 442
10년 전 조회 513
10년 전 조회 1,457
10년 전 조회 1,367
10년 전 조회 893
10년 전 조회 1,508
10년 전 조회 555
10년 전 조회 989
10년 전 조회 1,211
10년 전 조회 657
10년 전 조회 610
10년 전 조회 605
10년 전 조회 458
10년 전 조회 625
10년 전 조회 626
10년 전 조회 1,155
10년 전 조회 571
10년 전 조회 638
10년 전 조회 618
10년 전 조회 1,536
10년 전 조회 651
10년 전 조회 512
10년 전 조회 657
10년 전 조회 670
10년 전 조회 751
10년 전 조회 543
10년 전 조회 606
10년 전 조회 1,005
10년 전 조회 935
10년 전 조회 912
10년 전 조회 467
10년 전 조회 560
10년 전 조회 561
10년 전 조회 500
10년 전 조회 754
10년 전 조회 492
10년 전 조회 823
10년 전 조회 487
10년 전 조회 781
10년 전 조회 489
10년 전 조회 720
🐛 버그신고