2018-10-11 14:49:08 +00:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Controllers\Settings;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2020-04-16 20:29:26 +00:00
|
|
|
// use Illuminate\View\View;
|
|
|
|
// use Illuminate\Http\Request;
|
2018-10-11 14:49:08 +00:00
|
|
|
use App\Models\File;
|
|
|
|
|
|
|
|
class FileController extends Controller
|
|
|
|
{
|
|
|
|
public function download($id)
|
|
|
|
{
|
|
|
|
//$report = $this->report->find($id);
|
|
|
|
$file = File::findOrFail($id);
|
|
|
|
$file_path = public_path('storage/' . $file->path_name);
|
2019-09-23 15:44:42 +00:00
|
|
|
$ext = \Illuminate\Support\Facades\File::extension($file_path);
|
2020-04-16 20:29:26 +00:00
|
|
|
// return response()
|
|
|
|
// ->download(
|
|
|
|
// $file_path,
|
|
|
|
// $file->label . "." . $ext,
|
|
|
|
// ['Content-Type:' . $file->mime_type],
|
|
|
|
// 'inline'
|
|
|
|
// );
|
|
|
|
|
|
|
|
$pdf = $file->label . "." . $ext;
|
|
|
|
$download_file = \Illuminate\Support\Facades\File::get($file_path);
|
|
|
|
return response()->file($file_path, [
|
|
|
|
'Cache-Control' => 'no-cache private',
|
|
|
|
'Content-Description' => 'File Transfer',
|
|
|
|
'Content-Type' => $file->mime_type,
|
|
|
|
'Content-length' => strlen($download_file),
|
|
|
|
'Content-Disposition' => 'inline; filename=' . $pdf,
|
|
|
|
'Content-Transfer-Encoding' => 'binary'
|
|
|
|
]);
|
2019-09-23 15:44:42 +00:00
|
|
|
// return response()->download($file_path, $file->label, ['Content-Type:' . $file->mime_type]);
|
2018-10-11 14:49:08 +00:00
|
|
|
}
|
|
|
|
}
|