안

파일이름의 확장자로 파일 종류를 확인하는 함수

· 2006-11-30 (목) 21:47:38 · 2449
파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.


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;
}




// phpschool에서 펌<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

팁게시판

6,077건

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
07-03-22 조회 2,611
07-03-12 조회 3,345
07-02-16 조회 2,179
07-02-14 조회 3,981
07-02-10 조회 2,818
07-02-09 조회 3,180
07-01-19 조회 2,949
07-01-16 조회 3,824
06-12-16 조회 4,714
06-11-30 조회 2,450
06-11-25 조회 2,570
06-10-15 조회 3,989
06-09-26 조회 4,130
06-09-26 조회 4,286
06-09-22 조회 3,091
06-09-21 조회 2,553
06-09-21 조회 2,617
06-09-02 조회 2,378
06-08-08 조회 4,047
06-07-20 조회 2,749
06-07-17 조회 2,375
06-07-13 조회 3,201
06-07-11 조회 2,465
06-07-11 조회 2,488
06-07-11 조회 2,823