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

· 10년 전 · 337

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


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년 전 조회 374
10년 전 조회 434
10년 전 조회 392
10년 전 조회 451
10년 전 조회 445
10년 전 조회 425
10년 전 조회 592
10년 전 조회 603
10년 전 조회 371
10년 전 조회 668
10년 전 조회 1,017
10년 전 조회 476
10년 전 조회 696
10년 전 조회 704
10년 전 조회 527
10년 전 조회 480
10년 전 조회 443
10년 전 조회 542
10년 전 조회 317
10년 전 조회 349
10년 전 조회 568
10년 전 조회 404
10년 전 조회 364
10년 전 조회 352
10년 전 조회 372
10년 전 조회 370
10년 전 조회 352
10년 전 조회 358
10년 전 조회 390
10년 전 조회 482
10년 전 조회 321
10년 전 조회 361
10년 전 조회 438
10년 전 조회 1,163
10년 전 조회 373
10년 전 조회 371
10년 전 조회 494
10년 전 조회 373
10년 전 조회 547
10년 전 조회 486
10년 전 조회 371
10년 전 조회 371
10년 전 조회 423
10년 전 조회 421
10년 전 조회 311
10년 전 조회 313
10년 전 조회 268
10년 전 조회 323
10년 전 조회 718
10년 전 조회 338
10년 전 조회 441
10년 전 조회 359
10년 전 조회 555
10년 전 조회 370
10년 전 조회 308
10년 전 조회 335
10년 전 조회 354
10년 전 조회 484
10년 전 조회 432
10년 전 조회 280
10년 전 조회 341
10년 전 조회 1,303
10년 전 조회 1,194
10년 전 조회 737
10년 전 조회 1,343
10년 전 조회 389
10년 전 조회 825
10년 전 조회 1,040
10년 전 조회 494
10년 전 조회 444
10년 전 조회 443
10년 전 조회 296
10년 전 조회 443
10년 전 조회 466
10년 전 조회 992
10년 전 조회 394
10년 전 조회 467
10년 전 조회 449
10년 전 조회 1,372
10년 전 조회 476
10년 전 조회 333
10년 전 조회 487
10년 전 조회 507
10년 전 조회 581
10년 전 조회 378
10년 전 조회 438
10년 전 조회 838
10년 전 조회 768
10년 전 조회 745
10년 전 조회 300
10년 전 조회 386
10년 전 조회 390
10년 전 조회 330
10년 전 조회 599
10년 전 조회 319
10년 전 조회 657
10년 전 조회 319
10년 전 조회 616
10년 전 조회 318
10년 전 조회 540
🐛 버그신고