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

· 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년 전 조회 429
10년 전 조회 387
10년 전 조회 446
10년 전 조회 439
10년 전 조회 421
10년 전 조회 587
10년 전 조회 595
10년 전 조회 365
10년 전 조회 661
10년 전 조회 1,013
10년 전 조회 470
10년 전 조회 691
10년 전 조회 698
10년 전 조회 522
10년 전 조회 474
10년 전 조회 441
10년 전 조회 536
10년 전 조회 311
10년 전 조회 344
10년 전 조회 563
10년 전 조회 402
10년 전 조회 362
10년 전 조회 347
10년 전 조회 368
10년 전 조회 363
10년 전 조회 346
10년 전 조회 354
10년 전 조회 385
10년 전 조회 477
10년 전 조회 317
10년 전 조회 356
10년 전 조회 433
10년 전 조회 1,160
10년 전 조회 370
10년 전 조회 368
10년 전 조회 492
10년 전 조회 369
10년 전 조회 546
10년 전 조회 482
10년 전 조회 368
10년 전 조회 367
10년 전 조회 419
10년 전 조회 415
10년 전 조회 307
10년 전 조회 311
10년 전 조회 263
10년 전 조회 321
10년 전 조회 715
10년 전 조회 332
10년 전 조회 437
10년 전 조회 355
10년 전 조회 552
10년 전 조회 368
10년 전 조회 304
10년 전 조회 330
10년 전 조회 350
10년 전 조회 480
10년 전 조회 428
10년 전 조회 278
10년 전 조회 335
10년 전 조회 1,301
10년 전 조회 1,191
10년 전 조회 734
10년 전 조회 1,338
10년 전 조회 386
10년 전 조회 821
10년 전 조회 1,034
10년 전 조회 490
10년 전 조회 440
10년 전 조회 438
10년 전 조회 293
10년 전 조회 439
10년 전 조회 462
10년 전 조회 989
10년 전 조회 392
10년 전 조회 466
10년 전 조회 447
10년 전 조회 1,367
10년 전 조회 472
10년 전 조회 332
10년 전 조회 483
10년 전 조회 503
10년 전 조회 578
10년 전 조회 377
10년 전 조회 434
10년 전 조회 835
10년 전 조회 766
10년 전 조회 740
10년 전 조회 298
10년 전 조회 383
10년 전 조회 385
10년 전 조회 328
10년 전 조회 595
10년 전 조회 318
10년 전 조회 653
10년 전 조회 315
10년 전 조회 611
10년 전 조회 316
10년 전 조회 537
🐛 버그신고