파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5827 | 9년 전 | 361 | ||
| 5826 | 9년 전 | 351 | ||
| 5825 | 9년 전 | 315 | ||
| 5824 | 9년 전 | 478 | ||
| 5823 | 9년 전 | 479 | ||
| 5822 | 9년 전 | 277 | ||
| 5821 | 9년 전 | 591 | ||
| 5820 | 9년 전 | 889 | ||
| 5819 | 9년 전 | 427 | ||
| 5818 | 9년 전 | 569 | ||
| 5817 |
|
9년 전 | 1368 | |
| 5816 | 9년 전 | 396 | ||
| 5815 | 9년 전 | 369 | ||
| 5814 | 9년 전 | 348 | ||
| 5813 |
|
9년 전 | 1137 | |
| 5812 | 9년 전 | 445 | ||
| 5811 | 9년 전 | 228 | ||
| 5810 | 9년 전 | 262 | ||
| 5809 | 9년 전 | 469 | ||
| 5808 | 9년 전 | 311 | ||
| 5807 | 9년 전 | 282 | ||
| 5806 | 9년 전 | 263 | ||
| 5805 | 9년 전 | 283 | ||
| 5804 | 9년 전 | 280 | ||
| 5803 | 9년 전 | 267 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기