want to view pdf in the browser, but it started downloading automatically by IDM.
Here is my controller code ,
$filename = Pdf::find($id);
$path = asset($filename->pdf);
return Response::make(file_get_contents($path), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="' . $filename . '"',
]);
Here is my blade code,
<a href="{{route('preview.pdf',[$pdf->id])}}">view</a>
When I click on the view button, it started downloading automatically by IDM. I want to prevent it. No one can download the pdf, user can only view the pdf.
Does anyone know how to do it?
Laravel responce has a special file():
return response()->file($pathToFile);
The file method may be used to display a file, such as an image or PDF, directly in the user's browser instead of initiating a download
https://laravel.com/docs/6.x/responses#file-responses
According to the documentation, we should use this way.
To prevent forced downloads by IDM, in IDM configuration, you could do the following 2 ways:
PDF type