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

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


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,907
19년 전 조회 1,481
19년 전 조회 3,177
19년 전 조회 2,052
19년 전 조회 1,617
19년 전 조회 2,838
19년 전 조회 1,968
19년 전 조회 1,840
19년 전 조회 1,814
19년 전 조회 1,780
19년 전 조회 2,204
19년 전 조회 2,624
19년 전 조회 1,784
19년 전 조회 1,520
19년 전 조회 1,533
19년 전 조회 1,459
19년 전 조회 3,224
19년 전 조회 2,912
19년 전 조회 1,669
19년 전 조회 3,406
19년 전 조회 1,833
19년 전 조회 1,482
19년 전 조회 1,948
19년 전 조회 2,090
19년 전 조회 1,626
19년 전 조회 2,332
19년 전 조회 1,985
19년 전 조회 1,597
19년 전 조회 1,777
19년 전 조회 2,031
19년 전 조회 1,783
19년 전 조회 1,587
19년 전 조회 1,652
19년 전 조회 3,118
19년 전 조회 1,989
19년 전 조회 1,859
19년 전 조회 4,360
19년 전 조회 4,988
19년 전 조회 3,150
19년 전 조회 2,883
19년 전 조회 3,486
19년 전 조회 2,033
19년 전 조회 2,383
19년 전 조회 2,681
19년 전 조회 2,755
19년 전 조회 2,345
19년 전 조회 1,607
19년 전 조회 3,374
19년 전 조회 1,969
19년 전 조회 2,379
19년 전 조회 2,444
19년 전 조회 2,869
19년 전 조회 5,198
19년 전 조회 2,481
19년 전 조회 3,321
19년 전 조회 4,262
19년 전 조회 2,497
19년 전 조회 2,456
19년 전 조회 4,020
19년 전 조회 2,739
19년 전 조회 2,986
19년 전 조회 2,196
19년 전 조회 2,214
19년 전 조회 1,994
19년 전 조회 3,274
19년 전 조회 2,108
19년 전 조회 2,782
19년 전 조회 1,739
19년 전 조회 5,308
19년 전 조회 3,557
19년 전 조회 4,307
19년 전 조회 3,054
19년 전 조회 2,519
19년 전 조회 3,921
19년 전 조회 2,643
19년 전 조회 2,982
19년 전 조회 2,950
19년 전 조회 4,170
19년 전 조회 3,118
19년 전 조회 3,016
19년 전 조회 3,673
19년 전 조회 2,972
19년 전 조회 2,196
19년 전 조회 2,221
19년 전 조회 2,160
19년 전 조회 2,765
19년 전 조회 2,476
19년 전 조회 3,340
19년 전 조회 3,192
19년 전 조회 1,821
19년 전 조회 2,733
19년 전 조회 7,822
19년 전 조회 2,495
19년 전 조회 3,102
19년 전 조회 2,852
19년 전 조회 3,009
19년 전 조회 2,215
19년 전 조회 2,445
19년 전 조회 4,067
19년 전 조회 2,222
🐛 버그신고