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

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


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,486
19년 전 조회 3,184
19년 전 조회 2,056
19년 전 조회 1,623
19년 전 조회 2,841
19년 전 조회 1,973
19년 전 조회 1,844
19년 전 조회 1,820
19년 전 조회 1,786
19년 전 조회 2,208
19년 전 조회 2,631
19년 전 조회 1,789
19년 전 조회 1,527
19년 전 조회 1,535
19년 전 조회 1,462
19년 전 조회 3,227
19년 전 조회 2,918
19년 전 조회 1,674
19년 전 조회 3,409
19년 전 조회 1,836
19년 전 조회 1,486
19년 전 조회 1,952
19년 전 조회 2,095
19년 전 조회 1,630
19년 전 조회 2,337
19년 전 조회 1,992
19년 전 조회 1,601
19년 전 조회 1,783
19년 전 조회 2,036
19년 전 조회 1,785
19년 전 조회 1,589
19년 전 조회 1,655
19년 전 조회 3,123
19년 전 조회 1,992
19년 전 조회 1,863
19년 전 조회 4,364
19년 전 조회 4,995
19년 전 조회 3,157
19년 전 조회 2,888
19년 전 조회 3,491
19년 전 조회 2,037
19년 전 조회 2,388
19년 전 조회 2,685
19년 전 조회 2,759
19년 전 조회 2,346
19년 전 조회 1,609
19년 전 조회 3,376
19년 전 조회 1,974
19년 전 조회 2,386
19년 전 조회 2,447
19년 전 조회 2,872
19년 전 조회 5,201
19년 전 조회 2,482
19년 전 조회 3,324
19년 전 조회 4,264
19년 전 조회 2,503
19년 전 조회 2,456
19년 전 조회 4,025
19년 전 조회 2,744
19년 전 조회 2,990
19년 전 조회 2,200
19년 전 조회 2,219
19년 전 조회 1,998
19년 전 조회 3,279
19년 전 조회 2,112
19년 전 조회 2,787
19년 전 조회 1,743
19년 전 조회 5,312
19년 전 조회 3,561
19년 전 조회 4,312
19년 전 조회 3,059
19년 전 조회 2,524
19년 전 조회 3,923
19년 전 조회 2,647
19년 전 조회 2,988
19년 전 조회 2,951
19년 전 조회 4,174
19년 전 조회 3,120
19년 전 조회 3,021
19년 전 조회 3,676
19년 전 조회 2,974
19년 전 조회 2,202
19년 전 조회 2,224
19년 전 조회 2,163
19년 전 조회 2,769
19년 전 조회 2,482
19년 전 조회 3,345
19년 전 조회 3,197
19년 전 조회 1,824
19년 전 조회 2,738
19년 전 조회 7,826
19년 전 조회 2,498
19년 전 조회 3,108
19년 전 조회 2,856
19년 전 조회 3,014
19년 전 조회 2,217
19년 전 조회 2,449
19년 전 조회 4,073
19년 전 조회 2,223
🐛 버그신고