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

· 19년 전 · 2389
파일이름의 확장자로 파일 종류를 확인하는 함수입니다.
미디어스킨 또는 이미지 관련스킨에 유용할듯해서 올립니다.


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>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 1,913
19년 전 조회 1,490
19년 전 조회 3,185
19년 전 조회 2,058
19년 전 조회 1,624
19년 전 조회 2,843
19년 전 조회 1,975
19년 전 조회 1,849
19년 전 조회 1,822
19년 전 조회 1,788
19년 전 조회 2,210
19년 전 조회 2,633
19년 전 조회 1,792
19년 전 조회 1,530
19년 전 조회 1,536
19년 전 조회 1,468
19년 전 조회 3,231
19년 전 조회 2,922
19년 전 조회 1,676
19년 전 조회 3,413
19년 전 조회 1,839
19년 전 조회 1,489
19년 전 조회 1,954
19년 전 조회 2,097
19년 전 조회 1,635
19년 전 조회 2,339
19년 전 조회 1,995
19년 전 조회 1,603
19년 전 조회 1,784
19년 전 조회 2,040
19년 전 조회 1,788
19년 전 조회 1,593
19년 전 조회 1,657
19년 전 조회 3,127
19년 전 조회 1,994
19년 전 조회 1,868
19년 전 조회 4,368
19년 전 조회 4,995
19년 전 조회 3,157
19년 전 조회 2,890
19년 전 조회 3,496
19년 전 조회 2,039
19년 전 조회 2,391
19년 전 조회 2,686
19년 전 조회 2,762
19년 전 조회 2,348
19년 전 조회 1,611
19년 전 조회 3,377
19년 전 조회 1,975
19년 전 조회 2,390
19년 전 조회 2,449
19년 전 조회 2,873
19년 전 조회 5,202
19년 전 조회 2,483
19년 전 조회 3,326
19년 전 조회 4,265
19년 전 조회 2,508
19년 전 조회 2,460
19년 전 조회 4,031
19년 전 조회 2,748
19년 전 조회 2,993
19년 전 조회 2,205
19년 전 조회 2,221
19년 전 조회 2,000
19년 전 조회 3,281
19년 전 조회 2,114
19년 전 조회 2,790
19년 전 조회 1,744
19년 전 조회 5,316
19년 전 조회 3,562
19년 전 조회 4,315
19년 전 조회 3,060
19년 전 조회 2,528
19년 전 조회 3,927
19년 전 조회 2,648
19년 전 조회 2,990
19년 전 조회 2,957
19년 전 조회 4,178
19년 전 조회 3,123
19년 전 조회 3,025
19년 전 조회 3,678
19년 전 조회 2,976
19년 전 조회 2,207
19년 전 조회 2,225
19년 전 조회 2,166
19년 전 조회 2,770
19년 전 조회 2,485
19년 전 조회 3,348
19년 전 조회 3,198
19년 전 조회 1,826
19년 전 조회 2,741
19년 전 조회 7,828
19년 전 조회 2,500
19년 전 조회 3,112
19년 전 조회 2,861
19년 전 조회 3,018
19년 전 조회 2,221
19년 전 조회 2,452
19년 전 조회 4,075
19년 전 조회 2,225
🐛 버그신고