main
Ilham Wara Nugroho 2026-06-02 12:13:40 +07:00
parent 4c27b517c5
commit bb28501a05
2 changed files with 11 additions and 3 deletions

View File

@ -1751,7 +1751,7 @@ if (!function_exists('formKriteria')) {
<label class="fw-500">Dokumen '.$data->judul.'</label>
<div class="d-flex gap-2">
<a class="text-white btn btn-sm bg-primary" data-title="'.$data->judul.'" data-target="#modal" data-type="'.$extension[1].'" data-fancybox href="' . url('fileasset?path=/' . $checkFile->value) . '"href="#"><i class="fal fa-eye"></i>&nbsp; Preview</a>
<a class="text-white btn btn-sm bg-success" download data-title="'.$data->judul.'" data-type="'.$extension[1].'" href="' . url('fileasset?path=/' . $checkFile->value) . '"href="#"><i class="fal fa-download"></i>&nbsp; Download</a>
<a class="text-white btn btn-sm bg-success" data-title="'.$data->judul.'" data-type="'.$extension[1].'" href="' . url('fileasset?path=/' . $checkFile->value.'&&type=download') . '"href="#"><i class="fal fa-download"></i>&nbsp; Download</a>
</div>
</div>
<hr>';
@ -1776,7 +1776,7 @@ if (!function_exists('formKriteria')) {
<label class="fw-500">Dokumen '.$dataOption.'</label>
<div class="d-flex gap-2">
<a class="text-white btn btn-sm bg-primary" data-fancybox href="' . url('fileasset?path=/' . $checkFile->value) . '" href="#"><i class="fal fa-eye"></i>&nbsp; Preview</a>
<a class="text-white btn btn-sm bg-success" download href="' . url('fileasset?path=/' . $checkFile->value) . '" href="#"><i class="fal fa-download"></i>&nbsp; Download</a>
<a class="text-white btn btn-sm bg-success" href="' . url('fileasset?path=/' . $checkFile->value.'&&type=download') . '" href="#"><i class="fal fa-download"></i>&nbsp; Download</a>
</div>
</div>
<hr>';

View File

@ -30,6 +30,8 @@ class StorageController extends Controller
}
function fileasset(){
$path = request('path');
$type = request('type');
$content = 'inline';
try {
// 🔍 cek dulu file ada atau tidak
@ -37,6 +39,12 @@ class StorageController extends Controller
abort(404, 'File tidak ditemukan');
}
if (@$type == 'download'){
$content = 'attachment';
}else{
$content = 'inline';
}
$expl = explode('.',$path);
if($expl[1] == 'pdf'){
@ -63,7 +71,7 @@ class StorageController extends Controller
}
}, 200, [
'Content-Type' => $mime,
'Content-Disposition' => 'inline; filename="'.basename($path).'"',
'Content-Disposition' => $content.'; filename="'.basename($path).'"',
'X-Content-Type-Options' => 'nosniff',
]);