85 lines
2.4 KiB
PHP
85 lines
2.4 KiB
PHP
<?
|
|
include $_SERVER["DOCUMENT_ROOT"]."/common/common.php";
|
|
if ($_FILES['file']['name']) {
|
|
if (!$_FILES['file']['error']) {
|
|
//$name = md5(rand(100, 200));
|
|
//$ext = explode('.', $_FILES['file']['name']);
|
|
//$filename = $name . '.' . $ext[1];
|
|
|
|
// 업로드 폴더 설정
|
|
$currMonth = date("Ym",time());
|
|
|
|
// 임시 폴더
|
|
$_tmp_path = "tmp/";
|
|
|
|
// 업로드 절대 경로
|
|
$_server_path = _PDS;
|
|
$_base_path = "editor/";
|
|
$_upload_path = $_server_path.$_base_path.$currMonth."/";
|
|
$_tmp_upload = $_server_path.$_base_path.$_tmp_path;
|
|
|
|
// 웹 경로
|
|
$_base_web_path = "/pds/".$_base_path;
|
|
//$_base_web_path = "/pds/".$_base_path;
|
|
$_web_path = $_base_web_path.$currMonth."/";
|
|
$_tmp_web = $_base_web_path.$_tmp_path;
|
|
|
|
|
|
$name = $_FILES['file']['name'];
|
|
|
|
if(preg_match('/\\.(php|htm|html|asp|jsp|js|com|bat|txt)$/i', strtolower($name))){ // 확장자 금지항목 체크
|
|
//echo $message = '금지된 확장자의 파일 업로드를 시도하셨습니다. '.$_FILES['file']['error'];
|
|
echo "false";
|
|
exit;
|
|
}
|
|
else{
|
|
// 폴더 확인 및 생성
|
|
if(!file_exists($_upload_path)){
|
|
if(!mkdir($_upload_path, 0755)){
|
|
$_upload_path = $_tmp_upload;
|
|
$_web_path = $_tmp_web;
|
|
}
|
|
|
|
if(!chmod($_upload_path, 0755)){
|
|
$_upload_path = $_tmp_upload;
|
|
$_web_path = $_tmp_web;
|
|
}
|
|
}
|
|
|
|
$ArrFile=explode(".",$name);
|
|
$_ext=end($ArrFile);
|
|
$_upload=time()."_".RandInt(8).".".$_ext;
|
|
while(file_exists($_upload_path.$_upload)){
|
|
$_upload=time()."_".RandInt(8).".".$_ext;
|
|
}
|
|
|
|
$destination = $_upload_path . $_upload; //change this directory
|
|
$location = $_FILES["file"]["tmp_name"];
|
|
|
|
//thumb_upload($file,$dir,$type,$width="",$tmp_file=null);
|
|
|
|
|
|
$file_info = getimagesize($location);
|
|
$file_width = $file_info[0]; //이미지 가로 사이즈
|
|
$file_height = $file_info[1]; //이미지 세로 사이즈
|
|
$file_type = $_FILES['file']['type'];
|
|
|
|
if($file_width > 1110){
|
|
$img = thumb_upload($_FILES['file'],'/pds/editor/'.$currMonth,'T','1110');
|
|
}
|
|
else{
|
|
$img = thumb_upload($_FILES['file'],'/pds/editor/'.$currMonth,'O','');
|
|
}
|
|
|
|
//move_uploaded_file($location, $destination);
|
|
//echo $_web_path.$_upload;//change this URL
|
|
echo $_web_path.$img;//change this URL
|
|
exit;
|
|
}
|
|
} else {
|
|
//echo $message = 'Ooops! Your upload triggered the following error: '.$_FILES['file']['error'];
|
|
echo "false";
|
|
exit;
|
|
}
|
|
}
|
|
?>
|