파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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;
}
게시판 목록
팁게시판
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 27 | 21년 전 | 5788 | ||
| 26 | 21년 전 | 3065 | ||
| 25 | 21년 전 | 6055 | ||
| 24 | 18년 전 | 3651 | ||
| 23 | 21년 전 | 3611 | ||
| 22 | 21년 전 | 4218 | ||
| 21 | 21년 전 | 3804 | ||
| 20 | 21년 전 | 4175 | ||
| 19 | 21년 전 | 6628 | ||
| 18 | 21년 전 | 4711 | ||
| 17 | 21년 전 | 6945 | ||
| 16 | 21년 전 | 4151 | ||
| 15 | 21년 전 | 2603 | ||
| 14 | 21년 전 | 4950 | ||
| 13 | 21년 전 | 3377 | ||
| 12 |
Recluse
|
21년 전 | 3849 | |
| 11 |
아우겐나이스
|
21년 전 | 3533 | |
| 10 |
Recluse
|
21년 전 | 3356 | |
| 9 | 21년 전 | 3932 | ||
| 8 | 21년 전 | 5117 | ||
| 7 | 21년 전 | 4683 | ||
| 6 | 21년 전 | 5643 | ||
| 5 | 21년 전 | 4046 | ||
| 4 | 21년 전 | 4811 | ||
| 3 | 21년 전 | 4664 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기