Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

530
Vistas
How to view pdf without downloading in laravel?

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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Laravel responce has a special file():

return response()->file($pathToFile);
over 4 years ago · Santiago Trujillo Denunciar

0

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:

  1. Remove PDF type
  2. Specify your address where IDM will not download automatically

enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda