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

· 10년 전 · 422

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


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년 전 조회 482
10년 전 조회 533
10년 전 조회 500
10년 전 조회 551
10년 전 조회 548
10년 전 조회 535
10년 전 조회 695
10년 전 조회 703
10년 전 조회 470
10년 전 조회 768
10년 전 조회 1,123
10년 전 조회 570
10년 전 조회 804
10년 전 조회 813
10년 전 조회 635
10년 전 조회 573
10년 전 조회 555
10년 전 조회 653
10년 전 조회 426
10년 전 조회 458
10년 전 조회 678
10년 전 조회 510
10년 전 조회 464
10년 전 조회 464
10년 전 조회 474
10년 전 조회 473
10년 전 조회 450
10년 전 조회 455
10년 전 조회 485
10년 전 조회 590
10년 전 조회 423
10년 전 조회 447
10년 전 조회 528
10년 전 조회 1,271
10년 전 조회 485
10년 전 조회 475
10년 전 조회 602
10년 전 조회 493
10년 전 조회 665
10년 전 조회 597
10년 전 조회 475
10년 전 조회 478
10년 전 조회 534
10년 전 조회 519
10년 전 조회 417
10년 전 조회 411
10년 전 조회 375
10년 전 조회 426
10년 전 조회 822
10년 전 조회 423
10년 전 조회 541
10년 전 조회 454
10년 전 조회 654
10년 전 조회 474
10년 전 조회 385
10년 전 조회 432
10년 전 조회 457
10년 전 조회 580
10년 전 조회 526
10년 전 조회 373
10년 전 조회 430
10년 전 조회 1,402
10년 전 조회 1,293
10년 전 조회 832
10년 전 조회 1,432
10년 전 조회 485
10년 전 조회 929
10년 전 조회 1,129
10년 전 조회 582
10년 전 조회 538
10년 전 조회 534
10년 전 조회 379
10년 전 조회 553
10년 전 조회 553
10년 전 조회 1,085
10년 전 조회 489
10년 전 조회 575
10년 전 조회 537
10년 전 조회 1,473
10년 전 조회 576
10년 전 조회 439
10년 전 조회 576
10년 전 조회 601
10년 전 조회 672
10년 전 조회 467
10년 전 조회 529
10년 전 조회 927
10년 전 조회 857
10년 전 조회 845
10년 전 조회 387
10년 전 조회 482
10년 전 조회 477
10년 전 조회 414
10년 전 조회 686
10년 전 조회 416
10년 전 조회 749
10년 전 조회 417
10년 전 조회 714
10년 전 조회 401
10년 전 조회 629
🐛 버그신고