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

· 10년 전 · 328

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


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년 전 조회 360
10년 전 조회 417
10년 전 조회 379
10년 전 조회 440
10년 전 조회 430
10년 전 조회 412
10년 전 조회 578
10년 전 조회 588
10년 전 조회 355
10년 전 조회 655
10년 전 조회 1,008
10년 전 조회 460
10년 전 조회 683
10년 전 조회 687
10년 전 조회 516
10년 전 조회 468
10년 전 조회 434
10년 전 조회 527
10년 전 조회 302
10년 전 조회 336
10년 전 조회 554
10년 전 조회 388
10년 전 조회 354
10년 전 조회 339
10년 전 조회 356
10년 전 조회 354
10년 전 조회 338
10년 전 조회 345
10년 전 조회 377
10년 전 조회 467
10년 전 조회 308
10년 전 조회 346
10년 전 조회 425
10년 전 조회 1,153
10년 전 조회 361
10년 전 조회 359
10년 전 조회 487
10년 전 조회 362
10년 전 조회 538
10년 전 조회 474
10년 전 조회 361
10년 전 조회 360
10년 전 조회 413
10년 전 조회 408
10년 전 조회 299
10년 전 조회 305
10년 전 조회 256
10년 전 조회 311
10년 전 조회 708
10년 전 조회 329
10년 전 조회 425
10년 전 조회 346
10년 전 조회 545
10년 전 조회 361
10년 전 조회 298
10년 전 조회 323
10년 전 조회 344
10년 전 조회 470
10년 전 조회 416
10년 전 조회 267
10년 전 조회 325
10년 전 조회 1,288
10년 전 조회 1,185
10년 전 조회 721
10년 전 조회 1,332
10년 전 조회 379
10년 전 조회 814
10년 전 조회 1,027
10년 전 조회 483
10년 전 조회 432
10년 전 조회 431
10년 전 조회 286
10년 전 조회 434
10년 전 조회 456
10년 전 조회 980
10년 전 조회 385
10년 전 조회 458
10년 전 조회 436
10년 전 조회 1,361
10년 전 조회 465
10년 전 조회 327
10년 전 조회 478
10년 전 조회 497
10년 전 조회 569
10년 전 조회 372
10년 전 조회 429
10년 전 조회 828
10년 전 조회 760
10년 전 조회 735
10년 전 조회 290
10년 전 조회 374
10년 전 조회 378
10년 전 조회 317
10년 전 조회 586
10년 전 조회 311
10년 전 조회 648
10년 전 조회 307
10년 전 조회 603
10년 전 조회 305
10년 전 조회 531
🐛 버그신고