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

· 10년 전 · 331

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


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년 전 조회 369
10년 전 조회 427
10년 전 조회 387
10년 전 조회 446
10년 전 조회 436
10년 전 조회 420
10년 전 조회 585
10년 전 조회 593
10년 전 조회 364
10년 전 조회 659
10년 전 조회 1,013
10년 전 조회 466
10년 전 조회 690
10년 전 조회 698
10년 전 조회 521
10년 전 조회 474
10년 전 조회 439
10년 전 조회 536
10년 전 조회 311
10년 전 조회 343
10년 전 조회 562
10년 전 조회 400
10년 전 조회 359
10년 전 조회 347
10년 전 조회 367
10년 전 조회 361
10년 전 조회 345
10년 전 조회 352
10년 전 조회 384
10년 전 조회 475
10년 전 조회 317
10년 전 조회 353
10년 전 조회 430
10년 전 조회 1,159
10년 전 조회 369
10년 전 조회 366
10년 전 조회 491
10년 전 조회 369
10년 전 조회 543
10년 전 조회 480
10년 전 조회 365
10년 전 조회 367
10년 전 조회 419
10년 전 조회 412
10년 전 조회 307
10년 전 조회 309
10년 전 조회 263
10년 전 조회 319
10년 전 조회 715
10년 전 조회 331
10년 전 조회 435
10년 전 조회 353
10년 전 조회 550
10년 전 조회 367
10년 전 조회 302
10년 전 조회 329
10년 전 조회 350
10년 전 조회 480
10년 전 조회 427
10년 전 조회 275
10년 전 조회 333
10년 전 조회 1,300
10년 전 조회 1,190
10년 전 조회 730
10년 전 조회 1,338
10년 전 조회 386
10년 전 조회 821
10년 전 조회 1,034
10년 전 조회 488
10년 전 조회 439
10년 전 조회 435
10년 전 조회 291
10년 전 조회 437
10년 전 조회 462
10년 전 조회 988
10년 전 조회 390
10년 전 조회 466
10년 전 조회 446
10년 전 조회 1,367
10년 전 조회 469
10년 전 조회 331
10년 전 조회 483
10년 전 조회 502
10년 전 조회 575
10년 전 조회 377
10년 전 조회 433
10년 전 조회 834
10년 전 조회 763
10년 전 조회 739
10년 전 조회 296
10년 전 조회 381
10년 전 조회 381
10년 전 조회 326
10년 전 조회 593
10년 전 조회 317
10년 전 조회 652
10년 전 조회 313
10년 전 조회 610
10년 전 조회 314
10년 전 조회 536
🐛 버그신고