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

· 10년 전 · 342

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


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년 전 조회 394
10년 전 조회 453
10년 전 조회 409
10년 전 조회 469
10년 전 조회 460
10년 전 조회 446
10년 전 조회 607
10년 전 조회 616
10년 전 조회 383
10년 전 조회 677
10년 전 조회 1,032
10년 전 조회 491
10년 전 조회 713
10년 전 조회 713
10년 전 조회 544
10년 전 조회 493
10년 전 조회 457
10년 전 조회 555
10년 전 조회 333
10년 전 조회 365
10년 전 조회 581
10년 전 조회 417
10년 전 조회 379
10년 전 조회 362
10년 전 조회 385
10년 전 조회 385
10년 전 조회 361
10년 전 조회 370
10년 전 조회 401
10년 전 조회 494
10년 전 조회 333
10년 전 조회 372
10년 전 조회 446
10년 전 조회 1,176
10년 전 조회 387
10년 전 조회 377
10년 전 조회 504
10년 전 조회 379
10년 전 조회 556
10년 전 조회 497
10년 전 조회 383
10년 전 조회 375
10년 전 조회 429
10년 전 조회 429
10년 전 조회 319
10년 전 조회 324
10년 전 조회 277
10년 전 조회 329
10년 전 조회 727
10년 전 조회 343
10년 전 조회 445
10년 전 조회 367
10년 전 조회 565
10년 전 조회 375
10년 전 조회 311
10년 전 조회 340
10년 전 조회 361
10년 전 조회 488
10년 전 조회 437
10년 전 조회 286
10년 전 조회 347
10년 전 조회 1,310
10년 전 조회 1,202
10년 전 조회 742
10년 전 조회 1,349
10년 전 조회 394
10년 전 조회 832
10년 전 조회 1,044
10년 전 조회 499
10년 전 조회 446
10년 전 조회 448
10년 전 조회 298
10년 전 조회 449
10년 전 조회 469
10년 전 조회 996
10년 전 조회 399
10년 전 조회 475
10년 전 조회 454
10년 전 조회 1,379
10년 전 조회 480
10년 전 조회 341
10년 전 조회 493
10년 전 조회 512
10년 전 조회 587
10년 전 조회 386
10년 전 조회 440
10년 전 조회 842
10년 전 조회 774
10년 전 조회 750
10년 전 조회 308
10년 전 조회 394
10년 전 조회 394
10년 전 조회 335
10년 전 조회 604
10년 전 조회 325
10년 전 조회 665
10년 전 조회 323
10년 전 조회 623
10년 전 조회 325
10년 전 조회 550
🐛 버그신고