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

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


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,901
19년 전 조회 1,475
19년 전 조회 3,171
19년 전 조회 2,045
19년 전 조회 1,612
19년 전 조회 2,833
19년 전 조회 1,960
19년 전 조회 1,835
19년 전 조회 1,808
19년 전 조회 1,775
19년 전 조회 2,199
19년 전 조회 2,618
19년 전 조회 1,777
19년 전 조회 1,515
19년 전 조회 1,526
19년 전 조회 1,454
19년 전 조회 3,218
19년 전 조회 2,909
19년 전 조회 1,663
19년 전 조회 3,401
19년 전 조회 1,828
19년 전 조회 1,477
19년 전 조회 1,942
19년 전 조회 2,085
19년 전 조회 1,620
19년 전 조회 2,326
19년 전 조회 1,980
19년 전 조회 1,591
19년 전 조회 1,773
19년 전 조회 2,027
19년 전 조회 1,778
19년 전 조회 1,582
19년 전 조회 1,645
19년 전 조회 3,112
19년 전 조회 1,983
19년 전 조회 1,854
19년 전 조회 4,355
19년 전 조회 4,982
19년 전 조회 3,145
19년 전 조회 2,876
19년 전 조회 3,480
19년 전 조회 2,026
19년 전 조회 2,377
19년 전 조회 2,675
19년 전 조회 2,749
19년 전 조회 2,340
19년 전 조회 1,601
19년 전 조회 3,369
19년 전 조회 1,964
19년 전 조회 2,373
19년 전 조회 2,438
19년 전 조회 2,864
19년 전 조회 5,194
19년 전 조회 2,476
19년 전 조회 3,316
19년 전 조회 4,257
19년 전 조회 2,491
19년 전 조회 2,450
19년 전 조회 4,015
19년 전 조회 2,734
19년 전 조회 2,980
19년 전 조회 2,190
19년 전 조회 2,208
19년 전 조회 1,988
19년 전 조회 3,269
19년 전 조회 2,103
19년 전 조회 2,778
19년 전 조회 1,734
19년 전 조회 5,303
19년 전 조회 3,551
19년 전 조회 4,301
19년 전 조회 3,048
19년 전 조회 2,515
19년 전 조회 3,915
19년 전 조회 2,638
19년 전 조회 2,976
19년 전 조회 2,944
19년 전 조회 4,164
19년 전 조회 3,112
19년 전 조회 3,011
19년 전 조회 3,666
19년 전 조회 2,966
19년 전 조회 2,192
19년 전 조회 2,215
19년 전 조회 2,154
19년 전 조회 2,760
19년 전 조회 2,470
19년 전 조회 3,334
19년 전 조회 3,186
19년 전 조회 1,816
19년 전 조회 2,727
19년 전 조회 7,817
19년 전 조회 2,489
19년 전 조회 3,097
19년 전 조회 2,846
19년 전 조회 3,002
19년 전 조회 2,209
19년 전 조회 2,440
19년 전 조회 4,061
19년 전 조회 2,218
🐛 버그신고