From 6759c6fa52b783c85da07680334b62a188f23199 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 9 May 2023 17:49:18 +0700 Subject: [PATCH] fix upload dokumen --- app/Http/Controllers/ProjectDokumenController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ProjectDokumenController.php b/app/Http/Controllers/ProjectDokumenController.php index 466f09b..963208c 100644 --- a/app/Http/Controllers/ProjectDokumenController.php +++ b/app/Http/Controllers/ProjectDokumenController.php @@ -94,7 +94,12 @@ class ProjectDokumenController extends Controller if(!file_exists($this->pathDocument.$document->file)) return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - $pathToFile = $this->pathDocument.$document->file; - return response()->download($pathToFile); + $pathToFile = $this->pathDocument.$document->file; + $name = pathinfo($pathToFile, PATHINFO_FILENAME) . "." . pathinfo($pathToFile, PATHINFO_EXTENSION); + $headers = [ + 'Content-Disposition' => 'attachment; filename="'.$name.'"' + ]; + // dd($name, $headers); + return response()->download($pathToFile, $name, $headers); } }