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

· 10년 전 · 365

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


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년 전 조회 418
10년 전 조회 473
10년 전 조회 436
10년 전 조회 488
10년 전 조회 482
10년 전 조회 471
10년 전 조회 630
10년 전 조회 637
10년 전 조회 406
10년 전 조회 700
10년 전 조회 1,055
10년 전 조회 511
10년 전 조회 737
10년 전 조회 741
10년 전 조회 569
10년 전 조회 511
10년 전 조회 481
10년 전 조회 580
10년 전 조회 355
10년 전 조회 392
10년 전 조회 609
10년 전 조회 439
10년 전 조회 407
10년 전 조회 390
10년 전 조회 404
10년 전 조회 404
10년 전 조회 380
10년 전 조회 391
10년 전 조회 423
10년 전 조회 519
10년 전 조회 359
10년 전 조회 389
10년 전 조회 463
10년 전 조회 1,202
10년 전 조회 413
10년 전 조회 404
10년 전 조회 528
10년 전 조회 409
10년 전 조회 588
10년 전 조회 521
10년 전 조회 405
10년 전 조회 402
10년 전 조회 454
10년 전 조회 450
10년 전 조회 342
10년 전 조회 347
10년 전 조회 300
10년 전 조회 352
10년 전 조회 752
10년 전 조회 366
10년 전 조회 468
10년 전 조회 389
10년 전 조회 583
10년 전 조회 394
10년 전 조회 332
10년 전 조회 356
10년 전 조회 379
10년 전 조회 501
10년 전 조회 452
10년 전 조회 303
10년 전 조회 361
10년 전 조회 1,322
10년 전 조회 1,219
10년 전 조회 757
10년 전 조회 1,363
10년 전 조회 413
10년 전 조회 848
10년 전 조회 1,057
10년 전 조회 514
10년 전 조회 465
10년 전 조회 461
10년 전 조회 312
10년 전 조회 468
10년 전 조회 482
10년 전 조회 1,008
10년 전 조회 414
10년 전 조회 489
10년 전 조회 466
10년 전 조회 1,395
10년 전 조회 494
10년 전 조회 363
10년 전 조회 507
10년 전 조회 530
10년 전 조회 597
10년 전 조회 403
10년 전 조회 452
10년 전 조회 859
10년 전 조회 786
10년 전 조회 761
10년 전 조회 323
10년 전 조회 402
10년 전 조회 404
10년 전 조회 342
10년 전 조회 617
10년 전 조회 336
10년 전 조회 674
10년 전 조회 335
10년 전 조회 631
10년 전 조회 332
10년 전 조회 556
🐛 버그신고