파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5877 | 9년 전 | 258 | ||
| 5876 | 9년 전 | 311 | ||
| 5875 | 9년 전 | 296 | ||
| 5874 | 9년 전 | 320 | ||
| 5873 | 9년 전 | 426 | ||
| 5872 | 9년 전 | 319 | ||
| 5871 | 9년 전 | 276 | ||
| 5870 | 9년 전 | 301 | ||
| 5869 | 9년 전 | 414 | ||
| 5868 | 9년 전 | 314 | ||
| 5867 | 9년 전 | 264 | ||
| 5866 | 9년 전 | 263 | ||
| 5865 | 9년 전 | 272 | ||
| 5864 | 9년 전 | 227 | ||
| 5863 | 9년 전 | 227 | ||
| 5862 | 9년 전 | 412 | ||
| 5861 | 9년 전 | 463 | ||
| 5860 | 9년 전 | 255 | ||
| 5859 | 9년 전 | 248 | ||
| 5858 | 9년 전 | 218 | ||
| 5857 | 9년 전 | 249 | ||
| 5856 | 9년 전 | 345 | ||
| 5855 | 9년 전 | 295 | ||
| 5854 | 9년 전 | 200 | ||
| 5853 | 9년 전 | 251 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기