servermgrv2 init...
This commit is contained in:
parent
6011b2d40b
commit
6b8009c724
@ -49,7 +49,7 @@ class BoardController extends AdminController
|
||||
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
||||
break;
|
||||
case 'board_file':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity);
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->upload_file_procedure($field);
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
|
||||
@ -95,8 +95,11 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Upload FIle관련
|
||||
protected function upload_file_process(UploadedFile $upfile)
|
||||
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();
|
||||
@ -106,13 +109,34 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
return $fileName;
|
||||
}
|
||||
protected function single_upload_procedure(string $field, $entity = null)
|
||||
private function upload_image_process(UploadedFile $upfile, $sizeX = 100, $sizeY = 100)
|
||||
{
|
||||
if ($upfile = $this->request->getFile($field)) {
|
||||
return $this->upload_file_process($upfile);
|
||||
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()) {
|
||||
$originName = $upfile->getName();
|
||||
$fileName = $upfile->getRandomName();
|
||||
$image = \Config\Services::image();
|
||||
$image->withFile($upfile)
|
||||
->resize($sizeX, $sizeY, true, 'height')
|
||||
->save(FCPATH . '/upload_images/' . $fileName);
|
||||
$upfile->move(FCPATH . '/upload_images/', $fileName . "_original");
|
||||
$fileName = $originName . DEFAULTS['DELIMITER_FILE'] . $fileName;
|
||||
}
|
||||
return $fileName;
|
||||
}
|
||||
protected function multiple_upload_procedure(string $field, $entity = null): array
|
||||
protected function upload_file_procedure(string $field)
|
||||
{
|
||||
return $this->upload_file_process($this->request->getFile($field));
|
||||
}
|
||||
protected function upload_photo_procedure(string $field, $sizeX = 100, $sizeY = 100)
|
||||
{
|
||||
return $this->upload_image_process($this->request->getFile($field), $sizeX, $sizeY);
|
||||
}
|
||||
protected function upload_multiple_file_process(string $field): array
|
||||
{
|
||||
//Multiple파일의경우 html에서는 필드명[]를 넣어야하며
|
||||
//rule에서 "uploaded[필드명.0]|is_image[필드명]~~" 이런식으로 넣어야함
|
||||
@ -276,8 +300,6 @@ abstract class BaseController extends Controller
|
||||
{
|
||||
$titleField = $this->_model->getTitleField();
|
||||
$entity->$titleField = "RE: " . $entity->$titleField;
|
||||
$contentField = $this->_model->getContentField();
|
||||
$entity->$contentField .= "\n----------------------------------------------\n";
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class BoardController extends FrontController
|
||||
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
||||
break;
|
||||
case 'board_file':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity);
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->upload_file_procedure($field);
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user