From 82b2cc064840f49a80a2c37246dab36214ed80b5 Mon Sep 17 00:00:00 2001 From: maged-web Date: Sun, 5 May 2024 01:23:43 +0300 Subject: [PATCH] v4 --- app/Http/Controllers/HouseController.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/HouseController.php b/app/Http/Controllers/HouseController.php index 8786c9f6..7f98e98b 100644 --- a/app/Http/Controllers/HouseController.php +++ b/app/Http/Controllers/HouseController.php @@ -42,14 +42,9 @@ public function update(Request $request, House $house) public function download(House $house) { // TASK: Return the $house->photo file from "storage/app/houses" folder - // for download in browser - $filePath = storage_path("app/houses/{$house->photo}"); - if(file_exists($filePath)) - { - return Storage::download($filePath); - } - else { - return response()->json(['error' => 'File not found'], 404); - } + $filePath = storage_path('app/houses/' . $house->photo); + + return response()->download($filePath); + //return Storage::download('houses/' . $house->photo); } } \ No newline at end of file