コード例 #1
0
ファイル: Module.php プロジェクト: phpsong/ExtJS5-Yii2
 public function detachFile($id)
 {
     $file = File::findOne(['id' => $id]);
     $filePath = $this->getFilesDirPath($file->hash) . DIRECTORY_SEPARATOR . $file->hash . '.' . $file->type;
     unlink($filePath);
     $file->delete();
 }
コード例 #2
0
 public function actionDownload($id)
 {
     $file = File::findOne(['id' => $id]);
     $filePath = $this->getModule()->getFilesDirPath($file->hash) . DIRECTORY_SEPARATOR . $file->hash . '.' . $file->type;
     return \Yii::$app->response->sendFile($filePath, "{$file->name}.{$file->type}");
 }