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

· 10년 전 · 341

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


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년 전 조회 389
10년 전 조회 445
10년 전 조회 401
10년 전 조회 463
10년 전 조회 453
10년 전 조회 436
10년 전 조회 599
10년 전 조회 610
10년 전 조회 377
10년 전 조회 673
10년 전 조회 1,023
10년 전 조회 483
10년 전 조회 705
10년 전 조회 708
10년 전 조회 536
10년 전 조회 489
10년 전 조회 451
10년 전 조회 549
10년 전 조회 327
10년 전 조회 356
10년 전 조회 576
10년 전 조회 412
10년 전 조회 374
10년 전 조회 358
10년 전 조회 381
10년 전 조회 378
10년 전 조회 357
10년 전 조회 366
10년 전 조회 396
10년 전 조회 487
10년 전 조회 328
10년 전 조회 367
10년 전 조회 442
10년 전 조회 1,169
10년 전 조회 379
10년 전 조회 374
10년 전 조회 500
10년 전 조회 376
10년 전 조회 552
10년 전 조회 492
10년 전 조회 379
10년 전 조회 373
10년 전 조회 427
10년 전 조회 424
10년 전 조회 314
10년 전 조회 319
10년 전 조회 273
10년 전 조회 325
10년 전 조회 723
10년 전 조회 342
10년 전 조회 443
10년 전 조회 364
10년 전 조회 560
10년 전 조회 372
10년 전 조회 310
10년 전 조회 338
10년 전 조회 358
10년 전 조회 485
10년 전 조회 436
10년 전 조회 286
10년 전 조회 344
10년 전 조회 1,308
10년 전 조회 1,201
10년 전 조회 739
10년 전 조회 1,349
10년 전 조회 393
10년 전 조회 829
10년 전 조회 1,041
10년 전 조회 497
10년 전 조회 445
10년 전 조회 447
10년 전 조회 298
10년 전 조회 448
10년 전 조회 469
10년 전 조회 996
10년 전 조회 397
10년 전 조회 472
10년 전 조회 452
10년 전 조회 1,375
10년 전 조회 480
10년 전 조회 338
10년 전 조회 492
10년 전 조회 511
10년 전 조회 585
10년 전 조회 383
10년 전 조회 439
10년 전 조회 840
10년 전 조회 772
10년 전 조회 749
10년 전 조회 305
10년 전 조회 391
10년 전 조회 393
10년 전 조회 334
10년 전 조회 601
10년 전 조회 324
10년 전 조회 664
10년 전 조회 321
10년 전 조회 619
10년 전 조회 322
10년 전 조회 546
🐛 버그신고