public function actionSaveimage() { try { $res = array(); $this->get(); if (empty($_FILES['my-pic']) || empty($_FILES['my-pic']['tmp_name'])) { throw new Exception("EMPTY_FILE"); } $_img = $_FILES['my-pic']; if (empty($this->get['folder'])) { throw new Exception("NO_NAME_OF_FOLDER"); } $folder = trim($this->get['folder']); $id = 0; if (!(int) $this->get['id']) { throw new Exception("NO_CORRECT_NOTE_ID"); } $id = (int) $this->get['id']; if (!($path = $this->getImgFolderPath($id, $folder))) { throw new Exception("ERROR_CREATE_FOLDERS"); } $_img['name'] = myFunc::translitToUrl($_img['name'], true); include_once M_E_PATH . "/WideImage/WideImage.php"; $image = WideImage::load($_img['tmp_name'])->resize(500, 500, 'inside')->saveToFile($path . "/orig_" . $_img['name'], 100); //copy($_img['tmp_name'], $path."/orig_".$_img['name']); echo $this->getImgFolder($id, $folder) . "/orig_" . $_img['name']; $this->endApp(true); } catch (Exception $e) { $res['error'] = $e->getMessage(); } echo json_encode($res); $this->endApp(true); }