파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 77 | 20년 전 | 2908 | ||
| 76 | 20년 전 | 6211 | ||
| 75 | 20년 전 | 4453 | ||
| 74 | 20년 전 | 5752 | ||
| 73 | 20년 전 | 3607 | ||
| 72 | 20년 전 | 5940 | ||
| 71 | 20년 전 | 3097 | ||
| 70 | 20년 전 | 2819 | ||
| 69 | 20년 전 | 2624 | ||
| 68 | 20년 전 | 2436 | ||
| 67 | 20년 전 | 2644 | ||
| 66 | 20년 전 | 2663 | ||
| 65 | 20년 전 | 3793 | ||
| 64 | 20년 전 | 2805 | ||
| 63 | 20년 전 | 2396 | ||
| 62 | 20년 전 | 2241 | ||
| 61 | 20년 전 | 3031 | ||
| 60 | 20년 전 | 3100 | ||
| 59 | 20년 전 | 2484 | ||
| 58 | 20년 전 | 2568 | ||
| 57 | 20년 전 | 2942 | ||
| 56 | 20년 전 | 2244 | ||
| 55 | 20년 전 | 2724 | ||
| 54 | 20년 전 | 2097 | ||
| 53 | 20년 전 | 2328 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기