/** Uplaod file controller */ public function __upload() { s()->async(true); // Create object for uploading file to server $upload = new samson\upload\Upload(); // Uploading file to server; $upload->upload(); // Save path to file in DB samson\cms\input\Field::fromMetadata($_GET['e'], $_GET['f'], $_GET['i'])->save('cms' . $upload->file_path); // Return upload object for further usage return $upload; }
function gallery_async_upload() { $upload = new \samson\upload\Upload(array('jpg', 'JPG')); $upload->upload($filePath, $uploadName, $fileName); $_SESSION['filePath'] = $filePath; $_SESSION['uploadName'] = $uploadName; $_SESSION['fileName'] = $fileName; return array('status' => '1', 'filePath' => $filePath, 'uploadName' => $uploadName, 'fileName' => $fileName, 'sessionFilePath' => $_SESSION['filePath'], 'sessionUploadName' => $_SESSION['uploadName'], 'sessionFileName' => $_SESSION['fileName']); }