예제 #1
0
 public function run($table, $id)
 {
     if (Yii::$app->request->isPost) {
         $model = new FileUploadModel();
         $model->id = $id;
         $model->tableId = $table;
         $model->files[] = UploadedFile::getInstanceByName('files');
         if ($model->upload()) {
             return $model->getLink();
         } else {
             return ['error' => 'Не удалось загрузить файл'];
         }
     }
 }