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

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


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,477
19년 전 조회 3,175
19년 전 조회 2,050
19년 전 조회 1,615
19년 전 조회 2,836
19년 전 조회 1,964
19년 전 조회 1,839
19년 전 조회 1,813
19년 전 조회 1,779
19년 전 조회 2,201
19년 전 조회 2,621
19년 전 조회 1,781
19년 전 조회 1,517
19년 전 조회 1,531
19년 전 조회 1,454
19년 전 조회 3,222
19년 전 조회 2,912
19년 전 조회 1,665
19년 전 조회 3,404
19년 전 조회 1,832
19년 전 조회 1,481
19년 전 조회 1,946
19년 전 조회 2,086
19년 전 조회 1,622
19년 전 조회 2,330
19년 전 조회 1,983
19년 전 조회 1,595
19년 전 조회 1,776
19년 전 조회 2,030
19년 전 조회 1,780
19년 전 조회 1,585
19년 전 조회 1,646
19년 전 조회 3,115
19년 전 조회 1,987
19년 전 조회 1,856
19년 전 조회 4,358
19년 전 조회 4,985
19년 전 조회 3,148
19년 전 조회 2,881
19년 전 조회 3,482
19년 전 조회 2,029
19년 전 조회 2,381
19년 전 조회 2,679
19년 전 조회 2,752
19년 전 조회 2,341
19년 전 조회 1,604
19년 전 조회 3,372
19년 전 조회 1,967
19년 전 조회 2,375
19년 전 조회 2,442
19년 전 조회 2,867
19년 전 조회 5,196
19년 전 조회 2,479
19년 전 조회 3,319
19년 전 조회 4,260
19년 전 조회 2,495
19년 전 조회 2,454
19년 전 조회 4,019
19년 전 조회 2,735
19년 전 조회 2,983
19년 전 조회 2,193
19년 전 조회 2,212
19년 전 조회 1,992
19년 전 조회 3,273
19년 전 조회 2,106
19년 전 조회 2,782
19년 전 조회 1,737
19년 전 조회 5,306
19년 전 조회 3,555
19년 전 조회 4,303
19년 전 조회 3,051
19년 전 조회 2,518
19년 전 조회 3,919
19년 전 조회 2,641
19년 전 조회 2,980
19년 전 조회 2,948
19년 전 조회 4,167
19년 전 조회 3,116
19년 전 조회 3,014
19년 전 조회 3,668
19년 전 조회 2,969
19년 전 조회 2,194
19년 전 조회 2,217
19년 전 조회 2,158
19년 전 조회 2,764
19년 전 조회 2,474
19년 전 조회 3,338
19년 전 조회 3,189
19년 전 조회 1,820
19년 전 조회 2,730
19년 전 조회 7,820
19년 전 조회 2,493
19년 전 조회 3,101
19년 전 조회 2,851
19년 전 조회 3,005
19년 전 조회 2,212
19년 전 조회 2,444
19년 전 조회 4,064
19년 전 조회 2,220
🐛 버그신고