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

· 10년 전 · 353

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


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년 전 조회 407
10년 전 조회 461
10년 전 조회 423
10년 전 조회 481
10년 전 조회 473
10년 전 조회 458
10년 전 조회 619
10년 전 조회 629
10년 전 조회 397
10년 전 조회 691
10년 전 조회 1,041
10년 전 조회 503
10년 전 조회 726
10년 전 조회 727
10년 전 조회 557
10년 전 조회 502
10년 전 조회 469
10년 전 조회 567
10년 전 조회 340
10년 전 조회 378
10년 전 조회 594
10년 전 조회 427
10년 전 조회 393
10년 전 조회 374
10년 전 조회 391
10년 전 조회 397
10년 전 조회 373
10년 전 조회 382
10년 전 조회 415
10년 전 조회 506
10년 전 조회 345
10년 전 조회 381
10년 전 조회 454
10년 전 조회 1,186
10년 전 조회 401
10년 전 조회 388
10년 전 조회 514
10년 전 조회 390
10년 전 조회 568
10년 전 조회 505
10년 전 조회 391
10년 전 조회 387
10년 전 조회 437
10년 전 조회 435
10년 전 조회 327
10년 전 조회 330
10년 전 조회 285
10년 전 조회 339
10년 전 조회 736
10년 전 조회 354
10년 전 조회 452
10년 전 조회 376
10년 전 조회 572
10년 전 조회 383
10년 전 조회 321
10년 전 조회 346
10년 전 조회 370
10년 전 조회 492
10년 전 조회 443
10년 전 조회 292
10년 전 조회 349
10년 전 조회 1,313
10년 전 조회 1,211
10년 전 조회 748
10년 전 조회 1,354
10년 전 조회 401
10년 전 조회 839
10년 전 조회 1,050
10년 전 조회 507
10년 전 조회 457
10년 전 조회 452
10년 전 조회 304
10년 전 조회 457
10년 전 조회 474
10년 전 조회 1,001
10년 전 조회 406
10년 전 조회 480
10년 전 조회 458
10년 전 조회 1,383
10년 전 조회 484
10년 전 조회 347
10년 전 조회 496
10년 전 조회 517
10년 전 조회 590
10년 전 조회 393
10년 전 조회 445
10년 전 조회 847
10년 전 조회 777
10년 전 조회 754
10년 전 조회 309
10년 전 조회 396
10년 전 조회 398
10년 전 조회 337
10년 전 조회 609
10년 전 조회 328
10년 전 조회 668
10년 전 조회 328
10년 전 조회 625
10년 전 조회 326
10년 전 조회 551
🐛 버그신고