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

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


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,911
19년 전 조회 1,486
19년 전 조회 3,185
19년 전 조회 2,056
19년 전 조회 1,623
19년 전 조회 2,841
19년 전 조회 1,975
19년 전 조회 1,846
19년 전 조회 1,821
19년 전 조회 1,787
19년 전 조회 2,208
19년 전 조회 2,631
19년 전 조회 1,790
19년 전 조회 1,528
19년 전 조회 1,536
19년 전 조회 1,464
19년 전 조회 3,229
19년 전 조회 2,919
19년 전 조회 1,675
19년 전 조회 3,409
19년 전 조회 1,836
19년 전 조회 1,487
19년 전 조회 1,954
19년 전 조회 2,095
19년 전 조회 1,630
19년 전 조회 2,338
19년 전 조회 1,992
19년 전 조회 1,602
19년 전 조회 1,783
19년 전 조회 2,037
19년 전 조회 1,786
19년 전 조회 1,591
19년 전 조회 1,655
19년 전 조회 3,125
19년 전 조회 1,993
19년 전 조회 1,864
19년 전 조회 4,366
19년 전 조회 4,995
19년 전 조회 3,157
19년 전 조회 2,889
19년 전 조회 3,493
19년 전 조회 2,038
19년 전 조회 2,388
19년 전 조회 2,685
19년 전 조회 2,759
19년 전 조회 2,347
19년 전 조회 1,609
19년 전 조회 3,376
19년 전 조회 1,974
19년 전 조회 2,387
19년 전 조회 2,448
19년 전 조회 2,872
19년 전 조회 5,201
19년 전 조회 2,482
19년 전 조회 3,325
19년 전 조회 4,264
19년 전 조회 2,505
19년 전 조회 2,458
19년 전 조회 4,027
19년 전 조회 2,744
19년 전 조회 2,991
19년 전 조회 2,200
19년 전 조회 2,219
19년 전 조회 1,999
19년 전 조회 3,279
19년 전 조회 2,113
19년 전 조회 2,787
19년 전 조회 1,743
19년 전 조회 5,313
19년 전 조회 3,561
19년 전 조회 4,314
19년 전 조회 3,059
19년 전 조회 2,524
19년 전 조회 3,925
19년 전 조회 2,647
19년 전 조회 2,989
19년 전 조회 2,954
19년 전 조회 4,174
19년 전 조회 3,121
19년 전 조회 3,021
19년 전 조회 3,677
19년 전 조회 2,974
19년 전 조회 2,202
19년 전 조회 2,225
19년 전 조회 2,163
19년 전 조회 2,769
19년 전 조회 2,483
19년 전 조회 3,345
19년 전 조회 3,197
19년 전 조회 1,824
19년 전 조회 2,738
19년 전 조회 7,826
19년 전 조회 2,499
19년 전 조회 3,109
19년 전 조회 2,858
19년 전 조회 3,015
19년 전 조회 2,217
19년 전 조회 2,450
19년 전 조회 4,073
19년 전 조회 2,224
🐛 버그신고