예제 #1
0
 /**
  * Provides upload file
  * @return mixed
  */
 public function actionUpload()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new Mediafile();
     $routes = $this->module->routes;
     $rename = $this->module->rename;
     $model->saveUploadedFile($routes, $rename);
     $bundle = FilemanagerAsset::register($this->view);
     if ($model->isImage()) {
         $model->createThumbs($routes, $this->module->thumbs);
     }
     $response['files'][] = ['url' => $model->url, 'thumbnailUrl' => $model->getDefaultThumbUrl($bundle->baseUrl), 'name' => $model->filename, 'type' => $model->type, 'size' => $model->file->size, 'deleteUrl' => Url::to(['file/delete', 'id' => $model->id]), 'deleteType' => 'POST'];
     return $response;
 }