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

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


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,912
19년 전 조회 1,489
19년 전 조회 3,185
19년 전 조회 2,058
19년 전 조회 1,624
19년 전 조회 2,843
19년 전 조회 1,975
19년 전 조회 1,849
19년 전 조회 1,822
19년 전 조회 1,788
19년 전 조회 2,210
19년 전 조회 2,632
19년 전 조회 1,790
19년 전 조회 1,530
19년 전 조회 1,536
19년 전 조회 1,468
19년 전 조회 3,230
19년 전 조회 2,922
19년 전 조회 1,676
19년 전 조회 3,412
19년 전 조회 1,839
19년 전 조회 1,489
19년 전 조회 1,954
19년 전 조회 2,097
19년 전 조회 1,635
19년 전 조회 2,339
19년 전 조회 1,994
19년 전 조회 1,602
19년 전 조회 1,784
19년 전 조회 2,040
19년 전 조회 1,788
19년 전 조회 1,593
19년 전 조회 1,657
19년 전 조회 3,127
19년 전 조회 1,994
19년 전 조회 1,868
19년 전 조회 4,367
19년 전 조회 4,995
19년 전 조회 3,157
19년 전 조회 2,890
19년 전 조회 3,495
19년 전 조회 2,038
19년 전 조회 2,391
19년 전 조회 2,686
19년 전 조회 2,761
19년 전 조회 2,348
19년 전 조회 1,611
19년 전 조회 3,377
19년 전 조회 1,975
19년 전 조회 2,389
19년 전 조회 2,449
19년 전 조회 2,873
19년 전 조회 5,201
19년 전 조회 2,482
19년 전 조회 3,326
19년 전 조회 4,264
19년 전 조회 2,508
19년 전 조회 2,459
19년 전 조회 4,031
19년 전 조회 2,747
19년 전 조회 2,992
19년 전 조회 2,205
19년 전 조회 2,221
19년 전 조회 2,000
19년 전 조회 3,281
19년 전 조회 2,114
19년 전 조회 2,790
19년 전 조회 1,744
19년 전 조회 5,316
19년 전 조회 3,562
19년 전 조회 4,315
19년 전 조회 3,060
19년 전 조회 2,528
19년 전 조회 3,927
19년 전 조회 2,648
19년 전 조회 2,990
19년 전 조회 2,955
19년 전 조회 4,177
19년 전 조회 3,123
19년 전 조회 3,025
19년 전 조회 3,678
19년 전 조회 2,976
19년 전 조회 2,206
19년 전 조회 2,225
19년 전 조회 2,166
19년 전 조회 2,770
19년 전 조회 2,484
19년 전 조회 3,347
19년 전 조회 3,198
19년 전 조회 1,825
19년 전 조회 2,740
19년 전 조회 7,827
19년 전 조회 2,499
19년 전 조회 3,112
19년 전 조회 2,860
19년 전 조회 3,018
19년 전 조회 2,219
19년 전 조회 2,452
19년 전 조회 4,074
19년 전 조회 2,225
🐛 버그신고