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

· 10년 전 · 1336

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


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,347
10년 전 조회 1,380
10년 전 조회 1,374
10년 전 조회 1,405
10년 전 조회 1,435
10년 전 조회 1,403
10년 전 조회 1,561
10년 전 조회 1,547
10년 전 조회 1,338
10년 전 조회 1,641
10년 전 조회 1,989
10년 전 조회 1,439
10년 전 조회 1,691
10년 전 조회 1,654
10년 전 조회 1,515
10년 전 조회 1,462
10년 전 조회 1,430
10년 전 조회 1,536
10년 전 조회 1,270
10년 전 조회 1,362
10년 전 조회 1,587
10년 전 조회 1,403
10년 전 조회 1,399
10년 전 조회 1,346
10년 전 조회 1,389
10년 전 조회 1,372
10년 전 조회 1,377
10년 전 조회 1,407
10년 전 조회 1,353
10년 전 조회 1,516
10년 전 조회 1,339
10년 전 조회 1,350
10년 전 조회 1,441
10년 전 조회 2,171
10년 전 조회 1,414
10년 전 조회 1,397
10년 전 조회 1,473
10년 전 조회 1,391
10년 전 조회 1,583
10년 전 조회 1,479
10년 전 조회 1,400
10년 전 조회 1,401
10년 전 조회 1,447
10년 전 조회 1,425
10년 전 조회 1,345
10년 전 조회 1,304
10년 전 조회 1,283
10년 전 조회 1,317
10년 전 조회 1,707
10년 전 조회 1,337
10년 전 조회 1,455
10년 전 조회 1,401
10년 전 조회 1,632
10년 전 조회 1,431
10년 전 조회 1,374
10년 전 조회 1,389
10년 전 조회 1,418
10년 전 조회 1,542
10년 전 조회 1,485
10년 전 조회 1,370
10년 전 조회 1,407
10년 전 조회 2,349
10년 전 조회 2,214
10년 전 조회 1,799
10년 전 조회 2,362
10년 전 조회 1,434
10년 전 조회 1,836
10년 전 조회 2,068
10년 전 조회 1,557
10년 전 조회 1,512
10년 전 조회 1,481
10년 전 조회 1,340
10년 전 조회 1,517
10년 전 조회 1,526
10년 전 조회 2,028
10년 전 조회 1,464
10년 전 조회 1,516
10년 전 조회 1,531
10년 전 조회 2,444
10년 전 조회 1,566
10년 전 조회 1,456
10년 전 조회 1,544
10년 전 조회 1,591
10년 전 조회 1,669
10년 전 조회 1,466
10년 전 조회 1,515
10년 전 조회 1,867
10년 전 조회 1,821
10년 전 조회 1,803
10년 전 조회 1,358
10년 전 조회 1,464
10년 전 조회 1,427
10년 전 조회 1,383
10년 전 조회 1,603
10년 전 조회 1,373
10년 전 조회 1,680
10년 전 조회 1,349
10년 전 조회 1,689
10년 전 조회 1,381
10년 전 조회 1,620