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

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


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년 전 조회 2,043
19년 전 조회 1,609
19년 전 조회 3,292
19년 전 조회 2,176
19년 전 조회 1,731
19년 전 조회 2,970
19년 전 조회 2,097
19년 전 조회 1,976
19년 전 조회 1,940
19년 전 조회 1,904
19년 전 조회 2,333
19년 전 조회 2,753
19년 전 조회 1,903
19년 전 조회 1,655
19년 전 조회 1,654
19년 전 조회 1,613
19년 전 조회 3,338
19년 전 조회 3,037
19년 전 조회 1,773
19년 전 조회 3,539
19년 전 조회 1,966
19년 전 조회 1,604
19년 전 조회 2,076
19년 전 조회 2,219
19년 전 조회 1,779
19년 전 조회 2,462
19년 전 조회 2,109
19년 전 조회 1,726
19년 전 조회 1,910
19년 전 조회 2,162
19년 전 조회 1,929
19년 전 조회 1,712
19년 전 조회 1,776
19년 전 조회 3,271
19년 전 조회 2,126
19년 전 조회 1,991
19년 전 조회 4,485
19년 전 조회 5,111
19년 전 조회 3,280
19년 전 조회 3,019
19년 전 조회 3,621
19년 전 조회 2,158
19년 전 조회 2,521
19년 전 조회 2,813
19년 전 조회 2,881
19년 전 조회 2,482
19년 전 조회 1,742
19년 전 조회 3,528
19년 전 조회 2,100
19년 전 조회 2,504
19년 전 조회 2,569
19년 전 조회 3,012
19년 전 조회 5,334
19년 전 조회 2,604
19년 전 조회 3,444
19년 전 조회 4,381
19년 전 조회 2,638
19년 전 조회 2,579
19년 전 조회 4,166
19년 전 조회 2,870
19년 전 조회 3,105
19년 전 조회 2,335
19년 전 조회 2,331
19년 전 조회 2,122
19년 전 조회 3,418
19년 전 조회 2,231
19년 전 조회 2,917
19년 전 조회 1,871
19년 전 조회 5,423
19년 전 조회 3,686
19년 전 조회 4,440
19년 전 조회 3,183
19년 전 조회 2,652
19년 전 조회 4,041
19년 전 조회 2,772
19년 전 조회 3,115
19년 전 조회 3,091
19년 전 조회 4,292
19년 전 조회 3,251
19년 전 조회 3,132
19년 전 조회 3,825
19년 전 조회 3,112
19년 전 조회 2,344
19년 전 조회 2,344
19년 전 조회 2,287
19년 전 조회 2,901
19년 전 조회 2,602
19년 전 조회 3,462
19년 전 조회 3,323
19년 전 조회 1,946
19년 전 조회 2,864
19년 전 조회 7,943
19년 전 조회 2,629
19년 전 조회 3,236
19년 전 조회 3,001
19년 전 조회 3,125
19년 전 조회 2,339
19년 전 조회 2,579
19년 전 조회 4,179
19년 전 조회 2,364