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

· 10년 전 · 423

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


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년 전 조회 501
10년 전 조회 552
10년 전 조회 549
10년 전 조회 535
10년 전 조회 697
10년 전 조회 704
10년 전 조회 471
10년 전 조회 768
10년 전 조회 1,124
10년 전 조회 572
10년 전 조회 804
10년 전 조회 813
10년 전 조회 635
10년 전 조회 575
10년 전 조회 555
10년 전 조회 653
10년 전 조회 426
10년 전 조회 459
10년 전 조회 678
10년 전 조회 511
10년 전 조회 464
10년 전 조회 464
10년 전 조회 475
10년 전 조회 473
10년 전 조회 451
10년 전 조회 455
10년 전 조회 486
10년 전 조회 592
10년 전 조회 423
10년 전 조회 447
10년 전 조회 528
10년 전 조회 1,272
10년 전 조회 485
10년 전 조회 475
10년 전 조회 602
10년 전 조회 494
10년 전 조회 665
10년 전 조회 597
10년 전 조회 475
10년 전 조회 478
10년 전 조회 535
10년 전 조회 519
10년 전 조회 418
10년 전 조회 411
10년 전 조회 376
10년 전 조회 426
10년 전 조회 823
10년 전 조회 424
10년 전 조회 541
10년 전 조회 455
10년 전 조회 654
10년 전 조회 475
10년 전 조회 386
10년 전 조회 432
10년 전 조회 457
10년 전 조회 581
10년 전 조회 527
10년 전 조회 373
10년 전 조회 431
10년 전 조회 1,402
10년 전 조회 1,293
10년 전 조회 832
10년 전 조회 1,432
10년 전 조회 485
10년 전 조회 929
10년 전 조회 1,130
10년 전 조회 582
10년 전 조회 538
10년 전 조회 534
10년 전 조회 379
10년 전 조회 553
10년 전 조회 553
10년 전 조회 1,085
10년 전 조회 489
10년 전 조회 576
10년 전 조회 538
10년 전 조회 1,474
10년 전 조회 576
10년 전 조회 439
10년 전 조회 577
10년 전 조회 602
10년 전 조회 672
10년 전 조회 469
10년 전 조회 530
10년 전 조회 928
10년 전 조회 857
10년 전 조회 845
10년 전 조회 387
10년 전 조회 482
10년 전 조회 478
10년 전 조회 414
10년 전 조회 688
10년 전 조회 417
10년 전 조회 749
10년 전 조회 417
10년 전 조회 715
10년 전 조회 402
10년 전 조회 629
🐛 버그신고