function run() { if (isset($_FILES)) { $model = new FileUploadModel(); if ($model->upload()) { return $model->getResponse(); } else { return ['error' => 'Unable to save file']; } } }
function run() { if (isset($_FILES)) { $model = new FileUploadModel(['uploadDir' => $this->controller->module->uploadDir]); if ($model->upload()) { echo $model->toJson(); } else { if ($model->firstErrors) { echo Json::encode(['error' => $model->firstErrors[0]]); } } } }
public function run() { if (isset($_FILES)) { $model = new FileUploadModel(['uploadDir' => $this->uploadDir, 'baseDir' => $this->baseDir, 'baseUrl' => $this->baseUrl]); if ($model->upload()) { echo $model->toJson(); } else { if ($model->firstErrors) { echo Json::encode(['error' => $model->firstErrors[0]]); } } } }