From 63a6a266cd3a6ed27eb9a9a9fc2daa68d99f9294 Mon Sep 17 00:00:00 2001 From: Summer Date: Tue, 12 May 2020 12:12:37 +0800 Subject: [PATCH] Update AdminController.php --- src/controllers/AdminController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/controllers/AdminController.php b/src/controllers/AdminController.php index e149830..e42c061 100755 --- a/src/controllers/AdminController.php +++ b/src/controllers/AdminController.php @@ -440,16 +440,19 @@ public function displayFile() { //get the stored path of the original $path = $this->request->input('path'); - $data = File::get($path); - $file = new SFile($path); - $headers = array( - 'Content-Type' => $file->getMimeType(), - 'Content-Length' => $file->getSize(), - 'Content-Disposition' => 'attachment; filename="'.$file->getFilename().'"', - ); + if (File::exists($path)) { + $data = File::get($path); + $file = new SFile($path); + + $headers = array( + 'Content-Type' => $file->getMimeType(), + 'Content-Length' => $file->getSize(), + 'Content-Disposition' => 'attachment; filename="'.$file->getFilename().'"', + ); - return response()->make($data, 200, $headers); + return response()->make($data, 200, $headers); + } } /**