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

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


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;
}




// phpschool에서 펌<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 1,909
19년 전 조회 1,484
19년 전 조회 3,182
19년 전 조회 2,054
19년 전 조회 1,618
19년 전 조회 2,841
19년 전 조회 1,971
19년 전 조회 1,841
19년 전 조회 1,815
19년 전 조회 1,782
19년 전 조회 2,205
19년 전 조회 2,629
19년 전 조회 1,786
19년 전 조회 1,524
19년 전 조회 1,535
19년 전 조회 1,461
19년 전 조회 3,226
19년 전 조회 2,914
19년 전 조회 1,671
19년 전 조회 3,406
19년 전 조회 1,834
19년 전 조회 1,484
19년 전 조회 1,949
19년 전 조회 2,093
19년 전 조회 1,627
19년 전 조회 2,333
19년 전 조회 1,988
19년 전 조회 1,597
19년 전 조회 1,780
19년 전 조회 2,034
19년 전 조회 1,785
19년 전 조회 1,588
19년 전 조회 1,653
19년 전 조회 3,121
19년 전 조회 1,991
19년 전 조회 1,860
19년 전 조회 4,363
19년 전 조회 4,992
19년 전 조회 3,153
19년 전 조회 2,884
19년 전 조회 3,489
19년 전 조회 2,034
19년 전 조회 2,384
19년 전 조회 2,683
19년 전 조회 2,756
19년 전 조회 2,346
19년 전 조회 1,607
19년 전 조회 3,375
19년 전 조회 1,971
19년 전 조회 2,381
19년 전 조회 2,446
19년 전 조회 2,870
19년 전 조회 5,199
19년 전 조회 2,481
19년 전 조회 3,322
19년 전 조회 4,264
19년 전 조회 2,500
19년 전 조회 2,456
19년 전 조회 4,023
19년 전 조회 2,741
19년 전 조회 2,989
19년 전 조회 2,196
19년 전 조회 2,216
19년 전 조회 1,996
19년 전 조회 3,277
19년 전 조회 2,108
19년 전 조회 2,784
19년 전 조회 1,740
19년 전 조회 5,310
19년 전 조회 3,559
19년 전 조회 4,308
19년 전 조회 3,057
19년 전 조회 2,520
19년 전 조회 3,923
19년 전 조회 2,646
19년 전 조회 2,984
19년 전 조회 2,950
19년 전 조회 4,173
19년 전 조회 3,119
19년 전 조회 3,017
19년 전 조회 3,675
19년 전 조회 2,974
19년 전 조회 2,200
19년 전 조회 2,223
19년 전 조회 2,162
19년 전 조회 2,766
19년 전 조회 2,479
19년 전 조회 3,342
19년 전 조회 3,194
19년 전 조회 1,823
19년 전 조회 2,734
19년 전 조회 7,824
19년 전 조회 2,497
19년 전 조회 3,104
19년 전 조회 2,853
19년 전 조회 3,011
19년 전 조회 2,216
19년 전 조회 2,447
19년 전 조회 4,071
19년 전 조회 2,222
🐛 버그신고