diff --git a/app/Controllers/Board/Notice.php b/app/Controllers/Board/Notice.php index 1058f38..02a9aa9 100644 --- a/app/Controllers/Board/Notice.php +++ b/app/Controllers/Board/Notice.php @@ -2,6 +2,7 @@ namespace App\Controllers\board; use App\Controllers\BaseController; +use App\Libraries\MyUpload; use App\Models\board\NoticeModel; class Notice extends BaseController @@ -108,7 +109,7 @@ class Notice extends BaseController // 공지사항 작성 public function actWrite() { - + $lib = new MyUpload(); try { @@ -125,6 +126,37 @@ class Notice extends BaseController $file = $this->request->getFile('file'); if ($file && $file->isValid() && !$file->hasMoved()) { + + $uploadPath = "/upload/notice/" . date('Ymd') . "/"; + + $arrUploadfile = []; + if ($file->isValid() && !$file->hasMoved()) { + $uploadData = $lib->do_upload2($file, $uploadPath); + + if ($uploadData !== false) { + $arrUploadfile[] = $uploadData; + } + } + + if (!empty($arrUploadfile)) { + foreach ($arrUploadfile as $key => $uploadFile) { + $data['file'] = [ + 'file_sq' => $this->request->getPost('file_sq'), + 'orig_name' => $uploadFile['origin_name'], + 'new_name' => $uploadFile['file_name'], + 'file_path' => $uploadPath, // 필요에 따라 상대경로로만 저장 + 'ext' => '.' . $uploadFile['ext'], + 'size' => $file->getSize(), + 'img_yn' => null, + // 높이/폭은 나중에 getimagesize 등으로 구해도 됨 + 'img_height' => null, + 'img_width' => null, + ]; + } + + } + + /* $origName = $file->getClientName(); $ext = $file->getClientExtension(); $size = $file->getSize(); @@ -154,6 +186,8 @@ class Notice extends BaseController 'img_height' => null, 'img_width' => null, ]; + + */ } @@ -201,6 +235,8 @@ class Notice extends BaseController // 공지사항 수정요청 public function actModify() { + $lib = new MyUpload(); + try { $data = [ @@ -216,6 +252,36 @@ class Notice extends BaseController $file = $this->request->getFile('file'); if ($file && $file->isValid() && !$file->hasMoved()) { + $uploadPath = "/upload/notice/" . date('Ymd') . "/"; + + $arrUploadfile = []; + if ($file->isValid() && !$file->hasMoved()) { + $uploadData = $lib->do_upload2($file, $uploadPath); + + if ($uploadData !== false) { + $arrUploadfile[] = $uploadData; + } + } + + if (!empty($arrUploadfile)) { + foreach ($arrUploadfile as $key => $uploadFile) { + $data['file'] = [ + 'file_sq' => $this->request->getPost('file_sq'), + 'orig_name' => $uploadFile['origin_name'], + 'new_name' => $uploadFile['file_name'], + 'file_path' => $uploadPath, // 필요에 따라 상대경로로만 저장 + 'ext' => '.' . $uploadFile['ext'], + 'size' => $file->getSize(), + 'img_yn' => null, + // 높이/폭은 나중에 getimagesize 등으로 구해도 됨 + 'img_height' => null, + 'img_width' => null, + ]; + } + + } + + /* $origName = $file->getClientName(); $ext = $file->getClientExtension(); $size = $file->getSize(); @@ -247,6 +313,8 @@ class Notice extends BaseController 'img_height' => null, 'img_width' => null, ]; + + */ } diff --git a/app/Models/board/NoticeModel.php b/app/Models/board/NoticeModel.php index 06ef8b5..9d2ba1c 100644 --- a/app/Models/board/NoticeModel.php +++ b/app/Models/board/NoticeModel.php @@ -101,7 +101,7 @@ class NoticeModel extends Model $query = $this->db->query($sql, [$id]); $notice = $query->getRowArray(); - $sql = "SELECT bbs_sq, file_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name FROM bbs_file_notice WHERE bbs_sq = ?" . + $sql = "SELECT bbs_sq, file_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name, cloud_upload_yn FROM bbs_file_notice WHERE bbs_sq = ?" . " and use_yn = 'Y'"; $query = $this->db->query($sql, [$id]); $files = $query->getRowArray(); @@ -152,7 +152,7 @@ class NoticeModel extends Model $f = $data['file']; $sql = "INSERT INTO bbs_file_notice - (bbs_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name) + (bbs_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name, cloud_upload_yn) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $this->db->query($sql, [ @@ -165,6 +165,7 @@ class NoticeModel extends Model $f['img_height'] ?? null, $f['img_width'] ?? null, $f['orig_name'] ?? '', + 'Y' ]); } @@ -201,7 +202,7 @@ class NoticeModel extends Model if (empty($f['file_sq'])) { $sql = "INSERT INTO bbs_file_notice - (bbs_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name) + (bbs_sq, file_name, file_path, file_ext, file_size, img_yn, img_height, img_width, orig_name, cloud_upload_yn) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; $this->db->query($sql, [ @@ -214,6 +215,7 @@ class NoticeModel extends Model $f['img_height'] ?? null, $f['img_width'] ?? null, $f['orig_name'] ?? '', + 'Y' ]); } else { $sql = "UPDATE bbs_file_notice SET diff --git a/app/Views/layouts/sidebar.php b/app/Views/layouts/sidebar.php index a9b6632..4963089 100644 --- a/app/Views/layouts/sidebar.php +++ b/app/Views/layouts/sidebar.php @@ -101,6 +101,11 @@ // 3. 끝 슬래시 정리 $path = rtrim($path, '/'); switch ($path) { + case "/board/notice/write": + case "/board/notice/modify": + case "/board/notice/detail": + $path = "/board/notice/lists"; + break; case "/article/apt/detail": $path = "/article/apt/lists"; break; diff --git a/app/Views/pages/board/noticeDetail.php b/app/Views/pages/board/noticeDetail.php index c980f22..637d5f2 100644 --- a/app/Views/pages/board/noticeDetail.php +++ b/app/Views/pages/board/noticeDetail.php @@ -33,9 +33,16 @@