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

· 10년 전 · 333

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


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년 전 조회 373
10년 전 조회 433
10년 전 조회 390
10년 전 조회 448
10년 전 조회 442
10년 전 조회 424
10년 전 조회 590
10년 전 조회 601
10년 전 조회 367
10년 전 조회 666
10년 전 조회 1,016
10년 전 조회 472
10년 전 조회 694
10년 전 조회 702
10년 전 조회 524
10년 전 조회 477
10년 전 조회 442
10년 전 조회 540
10년 전 조회 316
10년 전 조회 346
10년 전 조회 566
10년 전 조회 404
10년 전 조회 362
10년 전 조회 350
10년 전 조회 371
10년 전 조회 366
10년 전 조회 349
10년 전 조회 356
10년 전 조회 387
10년 전 조회 478
10년 전 조회 320
10년 전 조회 359
10년 전 조회 436
10년 전 조회 1,162
10년 전 조회 372
10년 전 조회 369
10년 전 조회 494
10년 전 조회 371
10년 전 조회 547
10년 전 조회 486
10년 전 조회 370
10년 전 조회 367
10년 전 조회 420
10년 전 조회 418
10년 전 조회 309
10년 전 조회 312
10년 전 조회 266
10년 전 조회 322
10년 전 조회 715
10년 전 조회 334
10년 전 조회 438
10년 전 조회 358
10년 전 조회 554
10년 전 조회 368
10년 전 조회 304
10년 전 조회 333
10년 전 조회 351
10년 전 조회 481
10년 전 조회 429
10년 전 조회 278
10년 전 조회 338
10년 전 조회 1,301
10년 전 조회 1,193
10년 전 조회 736
10년 전 조회 1,341
10년 전 조회 388
10년 전 조회 822
10년 전 조회 1,038
10년 전 조회 492
10년 전 조회 442
10년 전 조회 442
10년 전 조회 294
10년 전 조회 442
10년 전 조회 464
10년 전 조회 991
10년 전 조회 393
10년 전 조회 466
10년 전 조회 448
10년 전 조회 1,370
10년 전 조회 472
10년 전 조회 332
10년 전 조회 486
10년 전 조회 504
10년 전 조회 579
10년 전 조회 377
10년 전 조회 438
10년 전 조회 836
10년 전 조회 767
10년 전 조회 743
10년 전 조회 299
10년 전 조회 385
10년 전 조회 388
10년 전 조회 329
10년 전 조회 598
10년 전 조회 318
10년 전 조회 655
10년 전 조회 316
10년 전 조회 612
10년 전 조회 317
10년 전 조회 539
🐛 버그신고