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

· 10년 전 · 470

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


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년 전 조회 515
10년 전 조회 568
10년 전 조회 527
10년 전 조회 585
10년 전 조회 582
10년 전 조회 571
10년 전 조회 731
10년 전 조회 735
10년 전 조회 500
10년 전 조회 805
10년 전 조회 1,164
10년 전 조회 607
10년 전 조회 846
10년 전 조회 840
10년 전 조회 676
10년 전 조회 608
10년 전 조회 595
10년 전 조회 691
10년 전 조회 464
10년 전 조회 497
10년 전 조회 713
10년 전 조회 545
10년 전 조회 509
10년 전 조회 492
10년 전 조회 508
10년 전 조회 511
10년 전 조회 486
10년 전 조회 504
10년 전 조회 529
10년 전 조회 622
10년 전 조회 462
10년 전 조회 486
10년 전 조회 569
10년 전 조회 1,314
10년 전 조회 524
10년 전 조회 518
10년 전 조회 649
10년 전 조회 529
10년 전 조회 714
10년 전 조회 633
10년 전 조회 523
10년 전 조회 520
10년 전 조회 572
10년 전 조회 566
10년 전 조회 462
10년 전 조회 458
10년 전 조회 418
10년 전 조회 472
10년 전 조회 869
10년 전 조회 470
10년 전 조회 589
10년 전 조회 500
10년 전 조회 709
10년 전 조회 515
10년 전 조회 435
10년 전 조회 486
10년 전 조회 504
10년 전 조회 634
10년 전 조회 565
10년 전 조회 418
10년 전 조회 491
10년 전 조회 1,438
10년 전 조회 1,339
10년 전 조회 870
10년 전 조회 1,488
10년 전 조회 531
10년 전 조회 974
10년 전 조회 1,182
10년 전 조회 626
10년 전 조회 590
10년 전 조회 588
10년 전 조회 437
10년 전 조회 609
10년 전 조회 610
10년 전 조회 1,141
10년 전 조회 552
10년 전 조회 615
10년 전 조회 591
10년 전 조회 1,518
10년 전 조회 622
10년 전 조회 485
10년 전 조회 642
10년 전 조회 654
10년 전 조회 727
10년 전 조회 516
10년 전 조회 587
10년 전 조회 976
10년 전 조회 913
10년 전 조회 896
10년 전 조회 439
10년 전 조회 537
10년 전 조회 531
10년 전 조회 468
10년 전 조회 734
10년 전 조회 464
10년 전 조회 798
10년 전 조회 465
10년 전 조회 763
10년 전 조회 461
10년 전 조회 692
🐛 버그신고