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

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


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,165
19년 전 조회 1,714
19년 전 조회 3,405
19년 전 조회 2,283
19년 전 조회 1,857
19년 전 조회 3,074
19년 전 조회 2,206
19년 전 조회 2,080
19년 전 조회 2,046
19년 전 조회 2,012
19년 전 조회 2,436
19년 전 조회 2,858
19년 전 조회 2,012
19년 전 조회 1,757
19년 전 조회 1,762
19년 전 조회 1,718
19년 전 조회 3,445
19년 전 조회 3,143
19년 전 조회 1,883
19년 전 조회 3,641
19년 전 조회 2,066
19년 전 조회 1,721
19년 전 조회 2,179
19년 전 조회 2,328
19년 전 조회 1,887
19년 전 조회 2,573
19년 전 조회 2,215
19년 전 조회 1,823
19년 전 조회 2,016
19년 전 조회 2,278
19년 전 조회 2,031
19년 전 조회 1,819
19년 전 조회 1,887
19년 전 조회 3,377
19년 전 조회 2,237
19년 전 조회 2,097
19년 전 조회 4,589
19년 전 조회 5,211
19년 전 조회 3,383
19년 전 조회 3,126
19년 전 조회 3,717
19년 전 조회 2,262
19년 전 조회 2,619
19년 전 조회 2,924
19년 전 조회 2,992
19년 전 조회 2,589
19년 전 조회 1,856
19년 전 조회 3,637
19년 전 조회 2,216
19년 전 조회 2,617
19년 전 조회 2,686
19년 전 조회 3,116
19년 전 조회 5,437
19년 전 조회 2,721
19년 전 조회 3,546
19년 전 조회 4,482
19년 전 조회 2,749
19년 전 조회 2,684
19년 전 조회 4,274
19년 전 조회 2,971
19년 전 조회 3,214
19년 전 조회 2,431
19년 전 조회 2,436
19년 전 조회 2,227
19년 전 조회 3,526
19년 전 조회 2,341
19년 전 조회 3,023
19년 전 조회 1,965
19년 전 조회 5,530
19년 전 조회 3,791
19년 전 조회 4,544
19년 전 조회 3,285
19년 전 조회 2,762
19년 전 조회 4,157
19년 전 조회 2,872
19년 전 조회 3,217
19년 전 조회 3,187
19년 전 조회 4,404
19년 전 조회 3,343
19년 전 조회 3,234
19년 전 조회 3,927
19년 전 조회 3,214
19년 전 조회 2,448
19년 전 조회 2,454
19년 전 조회 2,397
19년 전 조회 3,016
19년 전 조회 2,721
19년 전 조회 3,571
19년 전 조회 3,433
19년 전 조회 2,041
19년 전 조회 2,971
19년 전 조회 8,054
19년 전 조회 2,734
19년 전 조회 3,345
19년 전 조회 3,100
19년 전 조회 3,209
19년 전 조회 2,458
19년 전 조회 2,686
19년 전 조회 4,288
19년 전 조회 2,469