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

· 10년 전 · 467

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


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년 전 조회 513
10년 전 조회 567
10년 전 조회 527
10년 전 조회 584
10년 전 조회 582
10년 전 조회 571
10년 전 조회 731
10년 전 조회 735
10년 전 조회 500
10년 전 조회 805
10년 전 조회 1,163
10년 전 조회 606
10년 전 조회 846
10년 전 조회 840
10년 전 조회 676
10년 전 조회 606
10년 전 조회 594
10년 전 조회 690
10년 전 조회 464
10년 전 조회 497
10년 전 조회 713
10년 전 조회 545
10년 전 조회 507
10년 전 조회 492
10년 전 조회 507
10년 전 조회 511
10년 전 조회 486
10년 전 조회 503
10년 전 조회 528
10년 전 조회 621
10년 전 조회 462
10년 전 조회 484
10년 전 조회 568
10년 전 조회 1,314
10년 전 조회 524
10년 전 조회 514
10년 전 조회 647
10년 전 조회 529
10년 전 조회 713
10년 전 조회 631
10년 전 조회 520
10년 전 조회 518
10년 전 조회 572
10년 전 조회 566
10년 전 조회 461
10년 전 조회 457
10년 전 조회 416
10년 전 조회 470
10년 전 조회 868
10년 전 조회 468
10년 전 조회 587
10년 전 조회 500
10년 전 조회 707
10년 전 조회 514
10년 전 조회 434
10년 전 조회 484
10년 전 조회 501
10년 전 조회 631
10년 전 조회 565
10년 전 조회 417
10년 전 조회 488
10년 전 조회 1,438
10년 전 조회 1,338
10년 전 조회 870
10년 전 조회 1,487
10년 전 조회 529
10년 전 조회 972
10년 전 조회 1,178
10년 전 조회 623
10년 전 조회 589
10년 전 조회 586
10년 전 조회 436
10년 전 조회 607
10년 전 조회 608
10년 전 조회 1,138
10년 전 조회 549
10년 전 조회 615
10년 전 조회 589
10년 전 조회 1,518
10년 전 조회 621
10년 전 조회 484
10년 전 조회 640
10년 전 조회 653
10년 전 조회 726
10년 전 조회 515
10년 전 조회 584
10년 전 조회 975
10년 전 조회 912
10년 전 조회 895
10년 전 조회 438
10년 전 조회 537
10년 전 조회 531
10년 전 조회 467
10년 전 조회 734
10년 전 조회 464
10년 전 조회 798
10년 전 조회 465
10년 전 조회 763
10년 전 조회 461
10년 전 조회 692
🐛 버그신고