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

· 10년 전 · 462

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


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년 전 조회 508
10년 전 조회 561
10년 전 조회 521
10년 전 조회 580
10년 전 조회 578
10년 전 조회 564
10년 전 조회 725
10년 전 조회 729
10년 전 조회 495
10년 전 조회 798
10년 전 조회 1,158
10년 전 조회 604
10년 전 조회 837
10년 전 조회 837
10년 전 조회 670
10년 전 조회 599
10년 전 조회 587
10년 전 조회 684
10년 전 조회 458
10년 전 조회 492
10년 전 조회 710
10년 전 조회 539
10년 전 조회 499
10년 전 조회 488
10년 전 조회 498
10년 전 조회 502
10년 전 조회 481
10년 전 조회 494
10년 전 조회 520
10년 전 조회 613
10년 전 조회 455
10년 전 조회 478
10년 전 조회 560
10년 전 조회 1,312
10년 전 조회 516
10년 전 조회 508
10년 전 조회 642
10년 전 조회 526
10년 전 조회 706
10년 전 조회 629
10년 전 조회 511
10년 전 조회 512
10년 전 조회 567
10년 전 조회 562
10년 전 조회 455
10년 전 조회 453
10년 전 조회 410
10년 전 조회 463
10년 전 조회 861
10년 전 조회 463
10년 전 조회 580
10년 전 조회 494
10년 전 조회 697
10년 전 조회 509
10년 전 조회 428
10년 전 조회 475
10년 전 조회 494
10년 전 조회 624
10년 전 조회 558
10년 전 조회 410
10년 전 조회 483
10년 전 조회 1,435
10년 전 조회 1,333
10년 전 조회 865
10년 전 조회 1,479
10년 전 조회 524
10년 전 조회 966
10년 전 조회 1,169
10년 전 조회 614
10년 전 조회 583
10년 전 조회 575
10년 전 조회 424
10년 전 조회 596
10년 전 조회 602
10년 전 조회 1,130
10년 전 조회 540
10년 전 조회 612
10년 전 조회 583
10년 전 조회 1,511
10년 전 조회 613
10년 전 조회 479
10년 전 조회 631
10년 전 조회 643
10년 전 조회 723
10년 전 조회 511
10년 전 조회 576
10년 전 조회 971
10년 전 조회 904
10년 전 조회 886
10년 전 조회 432
10년 전 조회 529
10년 전 조회 523
10년 전 조회 459
10년 전 조회 729
10년 전 조회 457
10년 전 조회 793
10년 전 조회 458
10년 전 조회 758
10년 전 조회 454
10년 전 조회 683
🐛 버그신고