コード例 #1
0
 function run()
 {
     if (isset($_FILES)) {
         $model = new FileUploadModel();
         if ($model->upload()) {
             return $model->getResponse();
         } else {
             return ['error' => 'Unable to save file'];
         }
     }
 }
コード例 #2
0
 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]]);
             }
         }
     }
 }
コード例 #3
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]]);
             }
         }
     }
 }