파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5777 | 10년 전 | 442 | ||
| 5776 | 10년 전 | 295 | ||
| 5775 | 10년 전 | 224 | ||
| 5774 | 10년 전 | 902 | ||
| 5773 | 10년 전 | 262 | ||
| 5772 | 10년 전 | 289 | ||
| 5771 | 10년 전 | 404 | ||
| 5770 | 10년 전 | 351 | ||
| 5769 | 10년 전 | 213 | ||
| 5768 | 10년 전 | 264 | ||
| 5767 | 10년 전 | 1141 | ||
| 5766 | 10년 전 | 373 | ||
| 5765 | 10년 전 | 451 | ||
| 5764 | 10년 전 | 415 | ||
| 5763 | 10년 전 | 368 | ||
| 5762 | 10년 전 | 221 | ||
| 5761 | 10년 전 | 365 | ||
| 5760 | 10년 전 | 412 | ||
| 5759 | 10년 전 | 830 | ||
| 5758 | 10년 전 | 309 | ||
| 5757 | 10년 전 | 380 | ||
| 5756 | 10년 전 | 344 | ||
| 5755 | 10년 전 | 361 | ||
| 5754 | 10년 전 | 239 | ||
| 5753 | 10년 전 | 417 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기