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

· 10년 전 · 471

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


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년 전 조회 519
10년 전 조회 571
10년 전 조회 529
10년 전 조회 587
10년 전 조회 583
10년 전 조회 574
10년 전 조회 732
10년 전 조회 737
10년 전 조회 502
10년 전 조회 807
10년 전 조회 1,165
10년 전 조회 607
10년 전 조회 847
10년 전 조회 843
10년 전 조회 679
10년 전 조회 610
10년 전 조회 595
10년 전 조회 694
10년 전 조회 465
10년 전 조회 499
10년 전 조회 715
10년 전 조회 547
10년 전 조회 512
10년 전 조회 494
10년 전 조회 509
10년 전 조회 513
10년 전 조회 489
10년 전 조회 505
10년 전 조회 533
10년 전 조회 625
10년 전 조회 465
10년 전 조회 488
10년 전 조회 570
10년 전 조회 1,318
10년 전 조회 526
10년 전 조회 520
10년 전 조회 652
10년 전 조회 531
10년 전 조회 716
10년 전 조회 634
10년 전 조회 524
10년 전 조회 523
10년 전 조회 573
10년 전 조회 570
10년 전 조회 464
10년 전 조회 463
10년 전 조회 420
10년 전 조회 475
10년 전 조회 872
10년 전 조회 472
10년 전 조회 591
10년 전 조회 504
10년 전 조회 710
10년 전 조회 517
10년 전 조회 437
10년 전 조회 489
10년 전 조회 506
10년 전 조회 636
10년 전 조회 568
10년 전 조회 422
10년 전 조회 493
10년 전 조회 1,440
10년 전 조회 1,342
10년 전 조회 872
10년 전 조회 1,489
10년 전 조회 533
10년 전 조회 976
10년 전 조회 1,184
10년 전 조회 628
10년 전 조회 593
10년 전 조회 589
10년 전 조회 439
10년 전 조회 613
10년 전 조회 611
10년 전 조회 1,146
10년 전 조회 553
10년 전 조회 616
10년 전 조회 595
10년 전 조회 1,520
10년 전 조회 627
10년 전 조회 488
10년 전 조회 644
10년 전 조회 657
10년 전 조회 730
10년 전 조회 520
10년 전 조회 587
10년 전 조회 980
10년 전 조회 919
10년 전 조회 898
10년 전 조회 440
10년 전 조회 539
10년 전 조회 541
10년 전 조회 473
10년 전 조회 737
10년 전 조회 468
10년 전 조회 800
10년 전 조회 469
10년 전 조회 765
10년 전 조회 466
10년 전 조회 693
🐛 버그신고