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

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


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,912
19년 전 조회 1,487
19년 전 조회 3,185
19년 전 조회 2,058
19년 전 조회 1,624
19년 전 조회 2,843
19년 전 조회 1,975
19년 전 조회 1,847
19년 전 조회 1,822
19년 전 조회 1,787
19년 전 조회 2,210
19년 전 조회 2,632
19년 전 조회 1,790
19년 전 조회 1,530
19년 전 조회 1,536
19년 전 조회 1,467
19년 전 조회 3,230
19년 전 조회 2,922
19년 전 조회 1,675
19년 전 조회 3,412
19년 전 조회 1,836
19년 전 조회 1,488
19년 전 조회 1,954
19년 전 조회 2,097
19년 전 조회 1,631
19년 전 조회 2,338
19년 전 조회 1,993
19년 전 조회 1,602
19년 전 조회 1,784
19년 전 조회 2,038
19년 전 조회 1,787
19년 전 조회 1,591
19년 전 조회 1,656
19년 전 조회 3,126
19년 전 조회 1,994
19년 전 조회 1,865
19년 전 조회 4,366
19년 전 조회 4,995
19년 전 조회 3,157
19년 전 조회 2,890
19년 전 조회 3,494
19년 전 조회 2,038
19년 전 조회 2,388
19년 전 조회 2,686
19년 전 조회 2,760
19년 전 조회 2,348
19년 전 조회 1,610
19년 전 조회 3,376
19년 전 조회 1,974
19년 전 조회 2,388
19년 전 조회 2,448
19년 전 조회 2,872
19년 전 조회 5,201
19년 전 조회 2,482
19년 전 조회 3,326
19년 전 조회 4,264
19년 전 조회 2,505
19년 전 조회 2,458
19년 전 조회 4,027
19년 전 조회 2,745
19년 전 조회 2,992
19년 전 조회 2,201
19년 전 조회 2,220
19년 전 조회 1,999
19년 전 조회 3,279
19년 전 조회 2,114
19년 전 조회 2,787
19년 전 조회 1,743
19년 전 조회 5,315
19년 전 조회 3,562
19년 전 조회 4,314
19년 전 조회 3,060
19년 전 조회 2,525
19년 전 조회 3,926
19년 전 조회 2,647
19년 전 조회 2,989
19년 전 조회 2,955
19년 전 조회 4,176
19년 전 조회 3,123
19년 전 조회 3,022
19년 전 조회 3,678
19년 전 조회 2,974
19년 전 조회 2,204
19년 전 조회 2,225
19년 전 조회 2,164
19년 전 조회 2,770
19년 전 조회 2,484
19년 전 조회 3,345
19년 전 조회 3,197
19년 전 조회 1,824
19년 전 조회 2,739
19년 전 조회 7,827
19년 전 조회 2,499
19년 전 조회 3,111
19년 전 조회 2,860
19년 전 조회 3,017
19년 전 조회 2,217
19년 전 조회 2,451
19년 전 조회 4,073
19년 전 조회 2,224
🐛 버그신고