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

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


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,905
19년 전 조회 1,479
19년 전 조회 3,175
19년 전 조회 2,050
19년 전 조회 1,616
19년 전 조회 2,836
19년 전 조회 1,966
19년 전 조회 1,840
19년 전 조회 1,813
19년 전 조회 1,780
19년 전 조회 2,203
19년 전 조회 2,623
19년 전 조회 1,782
19년 전 조회 1,519
19년 전 조회 1,531
19년 전 조회 1,456
19년 전 조회 3,223
19년 전 조회 2,912
19년 전 조회 1,667
19년 전 조회 3,404
19년 전 조회 1,832
19년 전 조회 1,481
19년 전 조회 1,946
19년 전 조회 2,089
19년 전 조회 1,624
19년 전 조회 2,330
19년 전 조회 1,983
19년 전 조회 1,595
19년 전 조회 1,776
19년 전 조회 2,030
19년 전 조회 1,782
19년 전 조회 1,586
19년 전 조회 1,650
19년 전 조회 3,116
19년 전 조회 1,987
19년 전 조회 1,858
19년 전 조회 4,359
19년 전 조회 4,985
19년 전 조회 3,150
19년 전 조회 2,883
19년 전 조회 3,483
19년 전 조회 2,030
19년 전 조회 2,382
19년 전 조회 2,680
19년 전 조회 2,753
19년 전 조회 2,343
19년 전 조회 1,605
19년 전 조회 3,372
19년 전 조회 1,968
19년 전 조회 2,378
19년 전 조회 2,443
19년 전 조회 2,867
19년 전 조회 5,197
19년 전 조회 2,479
19년 전 조회 3,320
19년 전 조회 4,261
19년 전 조회 2,496
19년 전 조회 2,455
19년 전 조회 4,020
19년 전 조회 2,737
19년 전 조회 2,983
19년 전 조회 2,195
19년 전 조회 2,212
19년 전 조회 1,993
19년 전 조회 3,273
19년 전 조회 2,107
19년 전 조회 2,782
19년 전 조회 1,738
19년 전 조회 5,308
19년 전 조회 3,555
19년 전 조회 4,305
19년 전 조회 3,051
19년 전 조회 2,518
19년 전 조회 3,919
19년 전 조회 2,642
19년 전 조회 2,981
19년 전 조회 2,949
19년 전 조회 4,168
19년 전 조회 3,116
19년 전 조회 3,015
19년 전 조회 3,670
19년 전 조회 2,971
19년 전 조회 2,195
19년 전 조회 2,219
19년 전 조회 2,159
19년 전 조회 2,764
19년 전 조회 2,474
19년 전 조회 3,339
19년 전 조회 3,189
19년 전 조회 1,820
19년 전 조회 2,732
19년 전 조회 7,821
19년 전 조회 2,494
19년 전 조회 3,102
19년 전 조회 2,851
19년 전 조회 3,007
19년 전 조회 2,214
19년 전 조회 2,444
19년 전 조회 4,065
19년 전 조회 2,221
🐛 버그신고