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

--

--

--

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.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Kubernets / Rancher kubctl Important Commands / Terminal

Teach me Git and Github

HTML Form Tag

How to enable Large File Storage Github

Retrieving CoralNet Image Datasets Manually

“If it turns out that this is incurable, would you marry me?”

Going From Python to Kotlin: 10 Language Features to Know

What stops Coders from becoming Business Owners?

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.

More from Medium

How to send email in PHP with example

Laravel Nova, First impressions & Basic usage guide

Laravel 7 image upload tutorial example

Github | Project Documentation Compendium | Contributing GuideTemplates