How to Display PDF file in Laravel From Public Folder -

Steps to display PDF file in laravel

//for displaying PDF Route::get('/display_pdf','PdfController@index');
php artisan make:controller PdfController
<?php 
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use File;
use Response;
class PdfController extends Controller {
//
public function index(){
return Response::make(file_get_contents('images/image1.pdf'), 200, [ 'content-type'=>'application/pdf', ]);
}
}
http://127.0.0.1:8000/display_pdf

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bipsmedium

Bipsmedium

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.