32 lines
1.6 KiB
PHP
32 lines
1.6 KiB
PHP
<?php
|
|
include $_SERVER["DOCUMENT_ROOT"] . "/common/conf/config.inc.php";
|
|
|
|
if ($_FILES["file"]["error"] == 0){
|
|
//확장자 검사후 파일이름 생성
|
|
$filename = $_FILES["file"]["name"];
|
|
$attach_ext = explode(".",$filename);
|
|
$extension = $attach_ext[sizeof($attach_ext)-1];
|
|
$extension = strtolower($extension);
|
|
$filerename = md5($filename.microtime()) . "." . $extension;
|
|
$filesize = $_FILES["file"]["size"];
|
|
$filetype = strtolower($_FILES["file"]["type"]);
|
|
$mkdir = $_SITE["UPLOADED_DATA"] . "/summernote/" . date("Ym");
|
|
@mkdir($mkdir, 0755, true);
|
|
|
|
|
|
if(!strcmp($filetype,"image/png") || !strcmp($filetype,"image/jpg") || !strcmp($filetype,"image/jpeg") || !strcmp($filetype,"image/pjpeg") || !strcmp($filetype,"image/gif") || !strcmp($filetype,"image/tif") || !strcmp($filetype,"image/tiff") || !strcmp($filetype,"image/ico") || !strcmp($filetype,"image/svgz") || !strcmp($filetype,"image/webp") || !strcmp($filetype,"image/avif")){
|
|
// 파일 확장자 검사
|
|
if(!strcmp($extension,"htm") ||!strcmp($extension,"html") ||!strcmp($extension,"phtml") ||!strcmp($extension,"php") ||!strcmp($extension,"php3") ||!strcmp($extension,"php4") ||!strcmp($extension,"inc") ||!strcmp($extension,"pl") ||!strcmp($extension,"cgi") ||!strcmp($extension,"py") ||!strcmp($extension,"m3u8") ||!strcmp($extension,"sh")){
|
|
echo "NOT ALLOWED";
|
|
exit;
|
|
}
|
|
|
|
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {
|
|
move_uploaded_file ($_FILES["file"]["tmp_name"], $mkdir."/".$filerename);
|
|
echo "http://". $_SERVER["HTTP_HOST"] . "/uploaded/summernote/". date("Ym") . "/" . $filerename;
|
|
}
|
|
}
|
|
}else{
|
|
jsMsg("업로드 실패");
|
|
}
|
|
?>
|