From 8b92a2090caccea9673b5270a09ac8eea7e3d78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0git=20config=20git=20config=20-?= =?UTF-8?q?-helpgit=20config=20--global=20user=2Ename=20=EC=B5=9C=EC=A4=80?= =?UTF-8?q?=ED=9D=A0?= Date: Sat, 5 Aug 2023 22:20:24 +0900 Subject: [PATCH] servermgrv2 init... --- app/Config/Constants.php | 10 +++++++--- app/Controllers/BaseController.php | 14 ++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index c98800b..99bf708 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -181,11 +181,15 @@ define('AUTH_ADAPTERS', [ //Upload , Download 관련 define('PATHS', [ - 'EXCEL' => "excel/", 'UPLOAD' => "uploads/", 'DOWNLOAD' => "download/", 'API' => "api/", + 'EXCEL' => WRITEPATH . "excel/", + 'UPLOAD' => WRITEPATH . "uploads/", + 'UPLOAD_PHOTO' => FCPATH . 'upload_images/', + 'DOWNLOAD' => WRITEPATH . "download/", + 'API' => WRITEPATH . "api/", ]); foreach (PATHS as $key => $path) { - if (!is_dir(WRITEPATH . $path)) { - mkdir(WRITEPATH . $path, 0640); + if (!is_dir($path)) { + mkdir($path, 0640); } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index f359f1b..0695a87 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -97,13 +97,10 @@ abstract class BaseController extends Controller //Upload FIle관련 private function upload_file_process(UploadedFile $upfile) { - if (!is_dir(WRITEPATH . PATHS['UPLOAD'])) { - mkdir(WRITEPATH . PATHS['UPLOAD'], 0640); - } $fileName = null; if ($upfile->isValid() && !$upfile->hasMoved()) { $originName = $upfile->getName(); - $upfile->move(WRITEPATH . PATHS['UPLOAD'], $upfile->getRandomName()); + $upfile->move(PATHS['UPLOAD'], $upfile->getRandomName()); //move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요 $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $upfile->getName(); } @@ -111,9 +108,6 @@ abstract class BaseController extends Controller } private function upload_image_process(UploadedFile $upfile, $sizeX = 100, $sizeY = 100) { - if (!is_dir(FCPATH . '/upload_images')) { - mkdir(FCPATH . '/upload_images', 0640); - } //참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/ $fileName = null; if ($upfile->isValid() && !$upfile->hasMoved()) { @@ -122,8 +116,8 @@ abstract class BaseController extends Controller $image = \Config\Services::image(); $image->withFile($upfile) ->resize($sizeX, $sizeY, true, 'height') - ->save(FCPATH . '/upload_images/' . $fileName); - $upfile->move(FCPATH . '/upload_images/', "original_" . $fileName); + ->save(PATHS['UPLOAD_PHOTO'] . $fileName); + $upfile->move(PATHS['UPLOAD_PHOTO'], "original_" . $fileName); $fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $fileName; } return $fileName; @@ -575,7 +569,7 @@ abstract class BaseController extends Controller //setting return_url to session flashdata helper(['form']); $this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: ""); - return view($this->_viewPath . '/index', ['viewDatas' => $this->_viewDatas]); + return view($this->_viewPath . '/index' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]); } catch (\Exception $e) { return alert_CommonHelper($e->getMessage(), "back"); // return redirect()->back()->with('return_message', $e->getMessage());