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

· 10년 전 · 367

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


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년 전 조회 420
10년 전 조회 475
10년 전 조회 437
10년 전 조회 491
10년 전 조회 485
10년 전 조회 473
10년 전 조회 632
10년 전 조회 640
10년 전 조회 408
10년 전 조회 704
10년 전 조회 1,055
10년 전 조회 513
10년 전 조회 738
10년 전 조회 743
10년 전 조회 570
10년 전 조회 513
10년 전 조회 481
10년 전 조회 580
10년 전 조회 357
10년 전 조회 392
10년 전 조회 609
10년 전 조회 442
10년 전 조회 408
10년 전 조회 391
10년 전 조회 406
10년 전 조회 404
10년 전 조회 382
10년 전 조회 394
10년 전 조회 423
10년 전 조회 520
10년 전 조회 360
10년 전 조회 392
10년 전 조회 464
10년 전 조회 1,204
10년 전 조회 414
10년 전 조회 404
10년 전 조회 530
10년 전 조회 410
10년 전 조회 589
10년 전 조회 523
10년 전 조회 406
10년 전 조회 403
10년 전 조회 455
10년 전 조회 451
10년 전 조회 344
10년 전 조회 349
10년 전 조회 302
10년 전 조회 353
10년 전 조회 754
10년 전 조회 368
10년 전 조회 470
10년 전 조회 390
10년 전 조회 584
10년 전 조회 395
10년 전 조회 333
10년 전 조회 358
10년 전 조회 380
10년 전 조회 503
10년 전 조회 453
10년 전 조회 307
10년 전 조회 363
10년 전 조회 1,324
10년 전 조회 1,223
10년 전 조회 758
10년 전 조회 1,365
10년 전 조회 416
10년 전 조회 850
10년 전 조회 1,060
10년 전 조회 517
10년 전 조회 467
10년 전 조회 463
10년 전 조회 313
10년 전 조회 469
10년 전 조회 484
10년 전 조회 1,009
10년 전 조회 415
10년 전 조회 490
10년 전 조회 468
10년 전 조회 1,395
10년 전 조회 496
10년 전 조회 366
10년 전 조회 509
10년 전 조회 532
10년 전 조회 598
10년 전 조회 403
10년 전 조회 454
10년 전 조회 859
10년 전 조회 788
10년 전 조회 762
10년 전 조회 323
10년 전 조회 403
10년 전 조회 406
10년 전 조회 345
10년 전 조회 617
10년 전 조회 338
10년 전 조회 676
10년 전 조회 337
10년 전 조회 633
10년 전 조회 334
10년 전 조회 558
🐛 버그신고