파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.
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에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5677 |
패션리스트
|
10년 전 | 2372 | |
| 5676 |
패션리스트
|
10년 전 | 2330 | |
| 5675 | 10년 전 | 2251 | ||
| 5674 |
|
10년 전 | 1380 | |
| 5673 |
|
10년 전 | 2129 | |
| 5672 |
|
10년 전 | 1745 | |
| 5671 |
|
10년 전 | 2823 | |
| 5670 | 10년 전 | 1209 | ||
| 5669 |
|
10년 전 | 2010 | |
| 5668 | 10년 전 | 1100 | ||
| 5667 | 10년 전 | 1372 | ||
| 5666 |
|
10년 전 | 1713 | |
| 5665 |
|
10년 전 | 1265 | |
| 5664 |
|
10년 전 | 1003 | |
| 5663 | 10년 전 | 2452 | ||
| 5662 | 10년 전 | 997 | ||
| 5661 |
AniNest
|
10년 전 | 2694 | |
| 5660 |
untitled
|
10년 전 | 2317 | |
| 5659 |
프로그래머7
|
10년 전 | 1703 | |
| 5658 |
untitled
|
10년 전 | 2318 | |
| 5657 |
untitled
|
10년 전 | 1845 | |
| 5656 |
untitled
|
10년 전 | 2605 | |
| 5655 |
|
10년 전 | 2721 | |
| 5654 | 10년 전 | 1383 | ||
| 5653 |
|
10년 전 | 1789 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기