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

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


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,910
19년 전 조회 1,485
19년 전 조회 3,183
19년 전 조회 2,055
19년 전 조회 1,620
19년 전 조회 2,841
19년 전 조회 1,972
19년 전 조회 1,842
19년 전 조회 1,816
19년 전 조회 1,785
19년 전 조회 2,208
19년 전 조회 2,630
19년 전 조회 1,789
19년 전 조회 1,526
19년 전 조회 1,535
19년 전 조회 1,462
19년 전 조회 3,227
19년 전 조회 2,916
19년 전 조회 1,671
19년 전 조회 3,409
19년 전 조회 1,835
19년 전 조회 1,485
19년 전 조회 1,951
19년 전 조회 2,094
19년 전 조회 1,628
19년 전 조회 2,335
19년 전 조회 1,990
19년 전 조회 1,600
19년 전 조회 1,782
19년 전 조회 2,035
19년 전 조회 1,785
19년 전 조회 1,589
19년 전 조회 1,655
19년 전 조회 3,121
19년 전 조회 1,992
19년 전 조회 1,862
19년 전 조회 4,364
19년 전 조회 4,994
19년 전 조회 3,153
19년 전 조회 2,887
19년 전 조회 3,490
19년 전 조회 2,036
19년 전 조회 2,387
19년 전 조회 2,685
19년 전 조회 2,759
19년 전 조회 2,346
19년 전 조회 1,607
19년 전 조회 3,375
19년 전 조회 1,972
19년 전 조회 2,384
19년 전 조회 2,446
19년 전 조회 2,871
19년 전 조회 5,201
19년 전 조회 2,481
19년 전 조회 3,322
19년 전 조회 4,264
19년 전 조회 2,501
19년 전 조회 2,456
19년 전 조회 4,025
19년 전 조회 2,742
19년 전 조회 2,989
19년 전 조회 2,198
19년 전 조회 2,217
19년 전 조회 1,998
19년 전 조회 3,277
19년 전 조회 2,111
19년 전 조회 2,785
19년 전 조회 1,742
19년 전 조회 5,311
19년 전 조회 3,560
19년 전 조회 4,311
19년 전 조회 3,058
19년 전 조회 2,520
19년 전 조회 3,923
19년 전 조회 2,647
19년 전 조회 2,986
19년 전 조회 2,950
19년 전 조회 4,173
19년 전 조회 3,119
19년 전 조회 3,019
19년 전 조회 3,676
19년 전 조회 2,974
19년 전 조회 2,201
19년 전 조회 2,223
19년 전 조회 2,163
19년 전 조회 2,769
19년 전 조회 2,480
19년 전 조회 3,344
19년 전 조회 3,195
19년 전 조회 1,824
19년 전 조회 2,738
19년 전 조회 7,824
19년 전 조회 2,498
19년 전 조회 3,108
19년 전 조회 2,856
19년 전 조회 3,011
19년 전 조회 2,217
19년 전 조회 2,448
19년 전 조회 4,072
19년 전 조회 2,223
🐛 버그신고