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

· 10년 전 · 384

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


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년 전 조회 437
10년 전 조회 489
10년 전 조회 458
10년 전 조회 503
10년 전 조회 506
10년 전 조회 487
10년 전 조회 647
10년 전 조회 659
10년 전 조회 420
10년 전 조회 722
10년 전 조회 1,071
10년 전 조회 527
10년 전 조회 752
10년 전 조회 762
10년 전 조회 585
10년 전 조회 532
10년 전 조회 502
10년 전 조회 598
10년 전 조회 370
10년 전 조회 411
10년 전 조회 624
10년 전 조회 461
10년 전 조회 423
10년 전 조회 413
10년 전 조회 420
10년 전 조회 424
10년 전 조회 399
10년 전 조회 413
10년 전 조회 440
10년 전 조회 537
10년 전 조회 379
10년 전 조회 403
10년 전 조회 478
10년 전 조회 1,221
10년 전 조회 437
10년 전 조회 421
10년 전 조회 549
10년 전 조회 430
10년 전 조회 616
10년 전 조회 540
10년 전 조회 424
10년 전 조회 422
10년 전 조회 474
10년 전 조회 469
10년 전 조회 362
10년 전 조회 368
10년 전 조회 319
10년 전 조회 371
10년 전 조회 770
10년 전 조회 385
10년 전 조회 488
10년 전 조회 405
10년 전 조회 603
10년 전 조회 418
10년 전 조회 345
10년 전 조회 377
10년 전 조회 398
10년 전 조회 520
10년 전 조회 473
10년 전 조회 320
10년 전 조회 387
10년 전 조회 1,345
10년 전 조회 1,242
10년 전 조회 781
10년 전 조회 1,384
10년 전 조회 433
10년 전 조회 872
10년 전 조회 1,080
10년 전 조회 533
10년 전 조회 485
10년 전 조회 482
10년 전 조회 336
10년 전 조회 494
10년 전 조회 504
10년 전 조회 1,033
10년 전 조회 438
10년 전 조회 511
10년 전 조회 489
10년 전 조회 1,418
10년 전 조회 515
10년 전 조회 388
10년 전 조회 523
10년 전 조회 549
10년 전 조회 616
10년 전 조회 419
10년 전 조회 472
10년 전 조회 874
10년 전 조회 804
10년 전 조회 781
10년 전 조회 340
10년 전 조회 423
10년 전 조회 422
10년 전 조회 364
10년 전 조회 631
10년 전 조회 350
10년 전 조회 696
10년 전 조회 354
10년 전 조회 651
10년 전 조회 349
10년 전 조회 574
🐛 버그신고