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

· 10년 전 · 405

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


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년 전 조회 464
10년 전 조회 513
10년 전 조회 479
10년 전 조회 530
10년 전 조회 529
10년 전 조회 515
10년 전 조회 673
10년 전 조회 688
10년 전 조회 448
10년 전 조회 753
10년 전 조회 1,098
10년 전 조회 551
10년 전 조회 782
10년 전 조회 781
10년 전 조회 616
10년 전 조회 550
10년 전 조회 530
10년 전 조회 628
10년 전 조회 401
10년 전 조회 432
10년 전 조회 646
10년 전 조회 487
10년 전 조회 445
10년 전 조회 437
10년 전 조회 451
10년 전 조회 448
10년 전 조회 429
10년 전 조회 435
10년 전 조회 463
10년 전 조회 570
10년 전 조회 408
10년 전 조회 424
10년 전 조회 503
10년 전 조회 1,243
10년 전 조회 470
10년 전 조회 447
10년 전 조회 572
10년 전 조회 457
10년 전 조회 637
10년 전 조회 571
10년 전 조회 448
10년 전 조회 452
10년 전 조회 499
10년 전 조회 497
10년 전 조회 389
10년 전 조회 397
10년 전 조회 351
10년 전 조회 396
10년 전 조회 798
10년 전 조회 405
10년 전 조회 514
10년 전 조회 432
10년 전 조회 630
10년 전 조회 441
10년 전 조회 368
10년 전 조회 400
10년 전 조회 427
10년 전 조회 546
10년 전 조회 501
10년 전 조회 353
10년 전 조회 415
10년 전 조회 1,371
10년 전 조회 1,267
10년 전 조회 809
10년 전 조회 1,406
10년 전 조회 460
10년 전 조회 905
10년 전 조회 1,104
10년 전 조회 556
10년 전 조회 509
10년 전 조회 506
10년 전 조회 359
10년 전 조회 522
10년 전 조회 529
10년 전 조회 1,060
10년 전 조회 466
10년 전 조회 537
10년 전 조회 516
10년 전 조회 1,442
10년 전 조회 553
10년 전 조회 412
10년 전 조회 549
10년 전 조회 573
10년 전 조회 643
10년 전 조회 444
10년 전 조회 497
10년 전 조회 900
10년 전 조회 834
10년 전 조회 813
10년 전 조회 365
10년 전 조회 452
10년 전 조회 451
10년 전 조회 392
10년 전 조회 654
10년 전 조회 379
10년 전 조회 722
10년 전 조회 380
10년 전 조회 680
10년 전 조회 374
10년 전 조회 598
🐛 버그신고