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

· 10년 전 · 1437

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


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년 전 조회 1,423
10년 전 조회 1,472
10년 전 조회 1,462
10년 전 조회 1,496
10년 전 조회 1,525
10년 전 조회 1,494
10년 전 조회 1,644
10년 전 조회 1,630
10년 전 조회 1,432
10년 전 조회 1,741
10년 전 조회 2,068
10년 전 조회 1,532
10년 전 조회 1,779
10년 전 조회 1,749
10년 전 조회 1,588
10년 전 조회 1,575
10년 전 조회 1,523
10년 전 조회 1,622
10년 전 조회 1,371
10년 전 조회 1,450
10년 전 조회 1,665
10년 전 조회 1,489
10년 전 조회 1,462
10년 전 조회 1,438
10년 전 조회 1,463
10년 전 조회 1,477
10년 전 조회 1,470
10년 전 조회 1,489
10년 전 조회 1,441
10년 전 조회 1,610
10년 전 조회 1,441
10년 전 조회 1,449
10년 전 조회 1,559
10년 전 조회 2,266
10년 전 조회 1,512
10년 전 조회 1,481
10년 전 조회 1,563
10년 전 조회 1,481
10년 전 조회 1,661
10년 전 조회 1,567
10년 전 조회 1,485
10년 전 조회 1,481
10년 전 조회 1,512
10년 전 조회 1,504
10년 전 조회 1,439
10년 전 조회 1,390
10년 전 조회 1,374
10년 전 조회 1,414
10년 전 조회 1,809
10년 전 조회 1,438
10년 전 조회 1,538
10년 전 조회 1,482
10년 전 조회 1,722
10년 전 조회 1,534
10년 전 조회 1,454
10년 전 조회 1,481
10년 전 조회 1,520
10년 전 조회 1,642
10년 전 조회 1,564
10년 전 조회 1,459
10년 전 조회 1,497
10년 전 조회 2,448
10년 전 조회 2,323
10년 전 조회 1,878
10년 전 조회 2,458
10년 전 조회 1,524
10년 전 조회 1,925
10년 전 조회 2,164
10년 전 조회 1,653
10년 전 조회 1,597
10년 전 조회 1,574
10년 전 조회 1,435
10년 전 조회 1,611
10년 전 조회 1,605
10년 전 조회 2,124
10년 전 조회 1,535
10년 전 조회 1,608
10년 전 조회 1,612
10년 전 조회 2,534
10년 전 조회 1,664
10년 전 조회 1,549
10년 전 조회 1,634
10년 전 조회 1,675
10년 전 조회 1,745
10년 전 조회 1,545
10년 전 조회 1,623
10년 전 조회 1,968
10년 전 조회 1,920
10년 전 조회 1,897
10년 전 조회 1,451
10년 전 조회 1,555
10년 전 조회 1,504
10년 전 조회 1,468
10년 전 조회 1,690
10년 전 조회 1,462
10년 전 조회 1,757
10년 전 조회 1,446
10년 전 조회 1,781
10년 전 조회 1,479
10년 전 조회 1,705