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

· 10년 전 · 450

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


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년 전 조회 501
10년 전 조회 552
10년 전 조회 516
10년 전 조회 573
10년 전 조회 567
10년 전 조회 551
10년 전 조회 716
10년 전 조회 719
10년 전 조회 483
10년 전 조회 789
10년 전 조회 1,147
10년 전 조회 590
10년 전 조회 828
10년 전 조회 829
10년 전 조회 659
10년 전 조회 587
10년 전 조회 576
10년 전 조회 672
10년 전 조회 451
10년 전 조회 476
10년 전 조회 698
10년 전 조회 531
10년 전 조회 486
10년 전 조회 480
10년 전 조회 490
10년 전 조회 493
10년 전 조회 470
10년 전 조회 477
10년 전 조회 510
10년 전 조회 604
10년 전 조회 445
10년 전 조회 467
10년 전 조회 547
10년 전 조회 1,291
10년 전 조회 506
10년 전 조회 497
10년 전 조회 629
10년 전 조회 514
10년 전 조회 691
10년 전 조회 620
10년 전 조회 504
10년 전 조회 500
10년 전 조회 556
10년 전 조회 550
10년 전 조회 443
10년 전 조회 436
10년 전 조회 397
10년 전 조회 450
10년 전 조회 848
10년 전 조회 451
10년 전 조회 567
10년 전 조회 476
10년 전 조회 687
10년 전 조회 496
10년 전 조회 413
10년 전 조회 461
10년 전 조회 479
10년 전 조회 610
10년 전 조회 546
10년 전 조회 399
10년 전 조회 468
10년 전 조회 1,424
10년 전 조회 1,318
10년 전 조회 851
10년 전 조회 1,464
10년 전 조회 514
10년 전 조회 953
10년 전 조회 1,157
10년 전 조회 601
10년 전 조회 569
10년 전 조회 565
10년 전 조회 408
10년 전 조회 586
10년 전 조회 587
10년 전 조회 1,120
10년 전 조회 527
10년 전 조회 597
10년 전 조회 567
10년 전 조회 1,499
10년 전 조회 599
10년 전 조회 467
10년 전 조회 612
10년 전 조회 629
10년 전 조회 707
10년 전 조회 498
10년 전 조회 562
10년 전 조회 956
10년 전 조회 889
10년 전 조회 876
10년 전 조회 420
10년 전 조회 515
10년 전 조회 504
10년 전 조회 445
10년 전 조회 716
10년 전 조회 447
10년 전 조회 784
10년 전 조회 449
10년 전 조회 748
10년 전 조회 429
10년 전 조회 666
🐛 버그신고