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

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


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,478
19년 전 조회 3,175
19년 전 조회 2,050
19년 전 조회 1,615
19년 전 조회 2,836
19년 전 조회 1,965
19년 전 조회 1,839
19년 전 조회 1,813
19년 전 조회 1,779
19년 전 조회 2,202
19년 전 조회 2,621
19년 전 조회 1,782
19년 전 조회 1,518
19년 전 조회 1,531
19년 전 조회 1,455
19년 전 조회 3,223
19년 전 조회 2,912
19년 전 조회 1,667
19년 전 조회 3,404
19년 전 조회 1,832
19년 전 조회 1,481
19년 전 조회 1,946
19년 전 조회 2,088
19년 전 조회 1,623
19년 전 조회 2,330
19년 전 조회 1,983
19년 전 조회 1,595
19년 전 조회 1,776
19년 전 조회 2,030
19년 전 조회 1,780
19년 전 조회 1,585
19년 전 조회 1,647
19년 전 조회 3,115
19년 전 조회 1,987
19년 전 조회 1,856
19년 전 조회 4,358
19년 전 조회 4,985
19년 전 조회 3,150
19년 전 조회 2,882
19년 전 조회 3,482
19년 전 조회 2,030
19년 전 조회 2,382
19년 전 조회 2,680
19년 전 조회 2,752
19년 전 조회 2,343
19년 전 조회 1,604
19년 전 조회 3,372
19년 전 조회 1,967
19년 전 조회 2,376
19년 전 조회 2,443
19년 전 조회 2,867
19년 전 조회 5,196
19년 전 조회 2,479
19년 전 조회 3,320
19년 전 조회 4,260
19년 전 조회 2,495
19년 전 조회 2,455
19년 전 조회 4,020
19년 전 조회 2,737
19년 전 조회 2,983
19년 전 조회 2,194
19년 전 조회 2,212
19년 전 조회 1,992
19년 전 조회 3,273
19년 전 조회 2,106
19년 전 조회 2,782
19년 전 조회 1,737
19년 전 조회 5,307
19년 전 조회 3,555
19년 전 조회 4,304
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,669
19년 전 조회 2,969
19년 전 조회 2,194
19년 전 조회 2,219
19년 전 조회 2,159
19년 전 조회 2,764
19년 전 조회 2,474
19년 전 조회 3,339
19년 전 조회 3,189
19년 전 조회 1,820
19년 전 조회 2,731
19년 전 조회 7,820
19년 전 조회 2,493
19년 전 조회 3,102
19년 전 조회 2,851
19년 전 조회 3,006
19년 전 조회 2,212
19년 전 조회 2,444
19년 전 조회 4,065
19년 전 조회 2,220
🐛 버그신고