From a4fd1efd0276a2028ec2330b7b4ba7e2ff89442f Mon Sep 17 00:00:00 2001 From: Gabriel-31415 <gabriel.uag.ufrpe@gmail.com> Date: Fri, 2 Jul 2021 17:30:10 +0000 Subject: [PATCH] ajuste no hearders --- app/Http/Controllers/TrabalhoController.php | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/TrabalhoController.php b/app/Http/Controllers/TrabalhoController.php index 017bda0..44324c8 100644 --- a/app/Http/Controllers/TrabalhoController.php +++ b/app/Http/Controllers/TrabalhoController.php @@ -615,12 +615,32 @@ class TrabalhoController extends Controller if (Storage::disk()->exists($projeto->anexoPlanilhaPontuacao)) { ob_end_clean(); + $file = $projeto->anexoPlanilhaPontuacao; + $ext = explode(".", $file); + + // dd($ext); + switch ($ext[1]) { + case 'xlsx': + $hearder = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + break; + case 'xls': + $hearder = 'application/vnd.ms-excel'; + break; + case 'ods': + $hearder = 'application/vnd.oasis.opendocument.spreadsheet'; + break; + + default: + $hearder = 'application/vnd.ms-excel'; + break; + } $headers = array( - 'Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + "Content-type: {$hearder}", ); + - return Storage::download($projeto->anexoPlanilhaPontuacao, null,$headers); + return Storage::download($projeto->anexoPlanilhaPontuacao, "Planilha.{$ext[1]}",$headers); } return abort(404); } -- GitLab