파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5752 | 10년 전 | 485 | ||
| 5751 | 10년 전 | 531 | ||
| 5750 | 10년 전 | 329 | ||
| 5749 | 10년 전 | 405 | ||
| 5748 | 10년 전 | 802 | ||
| 5747 | 10년 전 | 578 | ||
| 5746 | 10년 전 | 293 | ||
| 5745 | 10년 전 | 335 | ||
| 5744 | 10년 전 | 341 | ||
| 5743 | 10년 전 | 278 | ||
| 5742 | 10년 전 | 284 | ||
| 5741 | 10년 전 | 633 | ||
| 5740 | 10년 전 | 311 | ||
| 5739 | 10년 전 | 304 | ||
| 5738 |
프로그램은어려워
|
10년 전 | 919 | |
| 5737 | 10년 전 | 497 | ||
| 5736 | 10년 전 | 394 | ||
| 5735 | 10년 전 | 397 | ||
| 5734 |
잘살아보자
|
10년 전 | 602 | |
| 5733 |
잘살아보자
|
10년 전 | 556 | |
| 5732 |
잘살아보자
|
10년 전 | 951 | |
| 5731 |
잘살아보자
|
10년 전 | 307 | |
| 5730 |
|
10년 전 | 1277 | |
| 5729 |
잘살아보자
|
10년 전 | 541 | |
| 5728 |
잘살아보자
|
10년 전 | 359 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기