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

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


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,185
19년 전 조회 1,731
19년 전 조회 3,426
19년 전 조회 2,309
19년 전 조회 1,877
19년 전 조회 3,096
19년 전 조회 2,231
19년 전 조회 2,099
19년 전 조회 2,067
19년 전 조회 2,036
19년 전 조회 2,463
19년 전 조회 2,877
19년 전 조회 2,031
19년 전 조회 1,773
19년 전 조회 1,787
19년 전 조회 1,738
19년 전 조회 3,463
19년 전 조회 3,170
19년 전 조회 1,913
19년 전 조회 3,663
19년 전 조회 2,087
19년 전 조회 1,748
19년 전 조회 2,202
19년 전 조회 2,342
19년 전 조회 1,906
19년 전 조회 2,594
19년 전 조회 2,235
19년 전 조회 1,847
19년 전 조회 2,028
19년 전 조회 2,294
19년 전 조회 2,059
19년 전 조회 1,836
19년 전 조회 1,900
19년 전 조회 3,396
19년 전 조회 2,255
19년 전 조회 2,115
19년 전 조회 4,612
19년 전 조회 5,231
19년 전 조회 3,409
19년 전 조회 3,143
19년 전 조회 3,748
19년 전 조회 2,285
19년 전 조회 2,641
19년 전 조회 2,945
19년 전 조회 3,008
19년 전 조회 2,603
19년 전 조회 1,873
19년 전 조회 3,651
19년 전 조회 2,237
19년 전 조회 2,638
19년 전 조회 2,701
19년 전 조회 3,134
19년 전 조회 5,457
19년 전 조회 2,737
19년 전 조회 3,557
19년 전 조회 4,514
19년 전 조회 2,770
19년 전 조회 2,704
19년 전 조회 4,294
19년 전 조회 2,988
19년 전 조회 3,231
19년 전 조회 2,444
19년 전 조회 2,463
19년 전 조회 2,241
19년 전 조회 3,543
19년 전 조회 2,356
19년 전 조회 3,045
19년 전 조회 1,986
19년 전 조회 5,544
19년 전 조회 3,812
19년 전 조회 4,560
19년 전 조회 3,296
19년 전 조회 2,772
19년 전 조회 4,164
19년 전 조회 2,890
19년 전 조회 3,232
19년 전 조회 3,201
19년 전 조회 4,414
19년 전 조회 3,358
19년 전 조회 3,250
19년 전 조회 3,938
19년 전 조회 3,225
19년 전 조회 2,461
19년 전 조회 2,480
19년 전 조회 2,414
19년 전 조회 3,037
19년 전 조회 2,733
19년 전 조회 3,588
19년 전 조회 3,442
19년 전 조회 2,060
19년 전 조회 2,989
19년 전 조회 8,073
19년 전 조회 2,750
19년 전 조회 3,370
19년 전 조회 3,113
19년 전 조회 3,234
19년 전 조회 2,468
19년 전 조회 2,696
19년 전 조회 4,306
19년 전 조회 2,480