Пример #1
0
 public function actionIndex($id)
 {
     $model = File::findOne($id);
     if ($model) {
         $model->updateCounters(['downloads' => 1]);
         Yii::$app->response->sendFile(Yii::getAlias('@webroot') . DIRECTORY_SEPARATOR . $model->file);
     } else {
         throw new \yii\web\NotFoundHttpException(Yii::t('easyii/file/api', 'File not found'));
     }
 }
Пример #2
0
 public function actionDelete($id)
 {
     if ($model = File::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/file', 'File deleted'));
 }