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

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


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,902
19년 전 조회 1,475
19년 전 조회 3,172
19년 전 조회 2,047
19년 전 조회 1,613
19년 전 조회 2,834
19년 전 조회 1,961
19년 전 조회 1,836
19년 전 조회 1,810
19년 전 조회 1,776
19년 전 조회 2,201
19년 전 조회 2,620
19년 전 조회 1,778
19년 전 조회 1,517
19년 전 조회 1,527
19년 전 조회 1,454
19년 전 조회 3,219
19년 전 조회 2,909
19년 전 조회 1,664
19년 전 조회 3,403
19년 전 조회 1,828
19년 전 조회 1,479
19년 전 조회 1,943
19년 전 조회 2,086
19년 전 조회 1,621
19년 전 조회 2,328
19년 전 조회 1,981
19년 전 조회 1,592
19년 전 조회 1,775
19년 전 조회 2,028
19년 전 조회 1,779
19년 전 조회 1,583
19년 전 조회 1,646
19년 전 조회 3,114
19년 전 조회 1,983
19년 전 조회 1,854
19년 전 조회 4,356
19년 전 조회 4,983
19년 전 조회 3,146
19년 전 조회 2,878
19년 전 조회 3,482
19년 전 조회 2,027
19년 전 조회 2,378
19년 전 조회 2,675
19년 전 조회 2,750
19년 전 조회 2,340
19년 전 조회 1,604
19년 전 조회 3,371
19년 전 조회 1,965
19년 전 조회 2,374
19년 전 조회 2,441
19년 전 조회 2,865
19년 전 조회 5,195
19년 전 조회 2,477
19년 전 조회 3,318
19년 전 조회 4,258
19년 전 조회 2,493
19년 전 조회 2,452
19년 전 조회 4,018
19년 전 조회 2,734
19년 전 조회 2,983
19년 전 조회 2,191
19년 전 조회 2,209
19년 전 조회 1,990
19년 전 조회 3,271
19년 전 조회 2,105
19년 전 조회 2,779
19년 전 조회 1,736
19년 전 조회 5,304
19년 전 조회 3,553
19년 전 조회 4,302
19년 전 조회 3,050
19년 전 조회 2,517
19년 전 조회 3,916
19년 전 조회 2,639
19년 전 조회 2,977
19년 전 조회 2,945
19년 전 조회 4,166
19년 전 조회 3,114
19년 전 조회 3,013
19년 전 조회 3,668
19년 전 조회 2,967
19년 전 조회 2,194
19년 전 조회 2,217
19년 전 조회 2,156
19년 전 조회 2,761
19년 전 조회 2,471
19년 전 조회 3,336
19년 전 조회 3,187
19년 전 조회 1,817
19년 전 조회 2,729
19년 전 조회 7,819
19년 전 조회 2,490
19년 전 조회 3,099
19년 전 조회 2,847
19년 전 조회 3,005
19년 전 조회 2,212
19년 전 조회 2,441
19년 전 조회 4,064
19년 전 조회 2,219
🐛 버그신고