공지사항 파일업로드 수정
Some checks failed
Close Pull Request / main (pull_request_target) Has been cancelled

This commit is contained in:
yangsh
2025-12-30 16:40:40 +09:00
parent fda9b9ab59
commit 38444fcb4f
13 changed files with 89 additions and 7 deletions

View File

@@ -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,
];
*/
}