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

· 10년 전 · 1272

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


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,274
10년 전 조회 1,312
10년 전 조회 1,308
10년 전 조회 1,343
10년 전 조회 1,363
10년 전 조회 1,344
10년 전 조회 1,491
10년 전 조회 1,491
10년 전 조회 1,275
10년 전 조회 1,576
10년 전 조회 1,935
10년 전 조회 1,366
10년 전 조회 1,630
10년 전 조회 1,586
10년 전 조회 1,438
10년 전 조회 1,401
10년 전 조회 1,357
10년 전 조회 1,478
10년 전 조회 1,218
10년 전 조회 1,291
10년 전 조회 1,510
10년 전 조회 1,337
10년 전 조회 1,330
10년 전 조회 1,290
10년 전 조회 1,313
10년 전 조회 1,309
10년 전 조회 1,303
10년 전 조회 1,325
10년 전 조회 1,273
10년 전 조회 1,445
10년 전 조회 1,275
10년 전 조회 1,278
10년 전 조회 1,360
10년 전 조회 2,104
10년 전 조회 1,326
10년 전 조회 1,320
10년 전 조회 1,421
10년 전 조회 1,320
10년 전 조회 1,487
10년 전 조회 1,399
10년 전 조회 1,326
10년 전 조회 1,325
10년 전 조회 1,376
10년 전 조회 1,353
10년 전 조회 1,267
10년 전 조회 1,225
10년 전 조회 1,195
10년 전 조회 1,233
10년 전 조회 1,620
10년 전 조회 1,273
10년 전 조회 1,377
10년 전 조회 1,332
10년 전 조회 1,557
10년 전 조회 1,356
10년 전 조회 1,309
10년 전 조회 1,309
10년 전 조회 1,343
10년 전 조회 1,459
10년 전 조회 1,392
10년 전 조회 1,291
10년 전 조회 1,333
10년 전 조회 2,263
10년 전 조회 2,143
10년 전 조회 1,712
10년 전 조회 2,269
10년 전 조회 1,333
10년 전 조회 1,767
10년 전 조회 1,992
10년 전 조회 1,473
10년 전 조회 1,437
10년 전 조회 1,411
10년 전 조회 1,269
10년 전 조회 1,444
10년 전 조회 1,447
10년 전 조회 1,948
10년 전 조회 1,379
10년 전 조회 1,437
10년 전 조회 1,460
10년 전 조회 2,363
10년 전 조회 1,505
10년 전 조회 1,385
10년 전 조회 1,471
10년 전 조회 1,515
10년 전 조회 1,602
10년 전 조회 1,391
10년 전 조회 1,450
10년 전 조회 1,793
10년 전 조회 1,749
10년 전 조회 1,721
10년 전 조회 1,279
10년 전 조회 1,400
10년 전 조회 1,354
10년 전 조회 1,303
10년 전 조회 1,518
10년 전 조회 1,306
10년 전 조회 1,604
10년 전 조회 1,283
10년 전 조회 1,605
10년 전 조회 1,292
10년 전 조회 1,540