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

· 10년 전 · 512

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


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년 전 조회 595
10년 전 조회 635
10년 전 조회 594
10년 전 조회 665
10년 전 조회 665
10년 전 조회 646
10년 전 조회 801
10년 전 조회 805
10년 전 조회 570
10년 전 조회 869
10년 전 조회 1,221
10년 전 조회 686
10년 전 조회 913
10년 전 조회 900
10년 전 조회 750
10년 전 조회 687
10년 전 조회 657
10년 전 조회 756
10년 전 조회 535
10년 전 조회 561
10년 전 조회 787
10년 전 조회 626
10년 전 조회 573
10년 전 조회 555
10년 전 조회 571
10년 전 조회 594
10년 전 조회 565
10년 전 조회 575
10년 전 조회 602
10년 전 조회 706
10년 전 조회 537
10년 전 조회 564
10년 전 조회 646
10년 전 조회 1,371
10년 전 조회 592
10년 전 조회 587
10년 전 조회 705
10년 전 조회 604
10년 전 조회 772
10년 전 조회 690
10년 전 조회 581
10년 전 조회 582
10년 전 조회 646
10년 전 조회 624
10년 전 조회 527
10년 전 조회 513
10년 전 조회 484
10년 전 조회 526
10년 전 조회 932
10년 전 조회 513
10년 전 조회 658
10년 전 조회 557
10년 전 조회 771
10년 전 조회 587
10년 전 조회 484
10년 전 조회 546
10년 전 조회 573
10년 전 조회 702
10년 전 조회 638
10년 전 조회 480
10년 전 조회 550
10년 전 조회 1,518
10년 전 조회 1,393
10년 전 조회 944
10년 전 조회 1,556
10년 전 조회 583
10년 전 조회 1,044
10년 전 조회 1,249
10년 전 조회 711
10년 전 조회 633
10년 전 조회 647
10년 전 조회 495
10년 전 조회 668
10년 전 조회 662
10년 전 조회 1,203
10년 전 조회 613
10년 전 조회 686
10년 전 조회 659
10년 전 조회 1,582
10년 전 조회 689
10년 전 조회 535
10년 전 조회 705
10년 전 조회 697
10년 전 조회 789
10년 전 조회 562
10년 전 조회 663
10년 전 조회 1,025
10년 전 조회 974
10년 전 조회 955
10년 전 조회 487
10년 전 조회 595
10년 전 조회 593
10년 전 조회 536
10년 전 조회 775
10년 전 조회 544
10년 전 조회 848
10년 전 조회 510
10년 전 조회 841
10년 전 조회 521
10년 전 조회 760
🐛 버그신고