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

· 10년 전 · 415

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


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년 전 조회 477
10년 전 조회 529
10년 전 조회 493
10년 전 조회 543
10년 전 조회 540
10년 전 조회 528
10년 전 조회 683
10년 전 조회 696
10년 전 조회 460
10년 전 조회 764
10년 전 조회 1,119
10년 전 조회 561
10년 전 조회 792
10년 전 조회 802
10년 전 조회 626
10년 전 조회 565
10년 전 조회 550
10년 전 조회 643
10년 전 조회 420
10년 전 조회 446
10년 전 조회 661
10년 전 조회 503
10년 전 조회 453
10년 전 조회 452
10년 전 조회 470
10년 전 조회 463
10년 전 조회 445
10년 전 조회 449
10년 전 조회 476
10년 전 조회 585
10년 전 조회 418
10년 전 조회 440
10년 전 조회 518
10년 전 조회 1,256
10년 전 조회 480
10년 전 조회 468
10년 전 조회 590
10년 전 조회 483
10년 전 조회 657
10년 전 조회 586
10년 전 조회 468
10년 전 조회 473
10년 전 조회 523
10년 전 조회 513
10년 전 조회 409
10년 전 조회 405
10년 전 조회 372
10년 전 조회 412
10년 전 조회 817
10년 전 조회 416
10년 전 조회 533
10년 전 조회 445
10년 전 조회 647
10년 전 조회 462
10년 전 조회 380
10년 전 조회 419
10년 전 조회 447
10년 전 조회 568
10년 전 조회 512
10년 전 조회 361
10년 전 조회 425
10년 전 조회 1,390
10년 전 조회 1,281
10년 전 조회 819
10년 전 조회 1,417
10년 전 조회 476
10년 전 조회 922
10년 전 조회 1,123
10년 전 조회 573
10년 전 조회 524
10년 전 조회 524
10년 전 조회 371
10년 전 조회 539
10년 전 조회 540
10년 전 조회 1,076
10년 전 조회 480
10년 전 조회 557
10년 전 조회 530
10년 전 조회 1,457
10년 전 조회 561
10년 전 조회 428
10년 전 조회 567
10년 전 조회 590
10년 전 조회 659
10년 전 조회 458
10년 전 조회 516
10년 전 조회 915
10년 전 조회 848
10년 전 조회 835
10년 전 조회 378
10년 전 조회 472
10년 전 조회 462
10년 전 조회 402
10년 전 조회 672
10년 전 조회 400
10년 전 조회 740
10년 전 조회 399
10년 전 조회 700
10년 전 조회 382
10년 전 조회 613
🐛 버그신고