title: Display pdf file from local disk in Laravel 5?
body: <p>I have a Laravel 5.5 app where users with administrator privileges can upload files. After they upload the files I'd like them to be able to view the file in the administrator dashboard.</p>
  
  <p>I have a <strong>DocumentController.php</strong> that handles the file upload to the local disk:</p>
  
  <pre><code>public function store(Request $request)
  {
      // check to make sure user is an admin
      $request-&gt;user()-&gt;authorizeRoles('admin');
  
      // validate that the document is a pdf and 
      // that required fields are filled out
      $this-&gt;validate($request, [
          'title' =&gt; 'required',
          'description' =&gt; 'required',
          'user_id' =&gt; 'required|exists:users,id', 
          'document_path' =&gt; 'required|mimes:pdf'
      ]);
  
      $file = $request-&gt;file('document_path');
  
      $path = $file-&gt;store('documents/' . $request-&gt;user_id);
  
      $document = Document::create([
          'user_id' =&gt; $request-&gt;user_id,
          'title' =&gt; $request-&gt;title,
          'description' =&gt; $request-&gt;description,
          'file_path' =&gt; $path
      ]);
  
      return redirect($document-&gt;path());
  } 
  </code></pre>
  
  <p>This method takes the file from the form, makes sure it is a pdf and then saves the file to <strong>storage/app/documents/{user_id}</strong>. It then creates a Document record in the database and forwards to the URL based on the document id: <strong>/admin/document/{ $document->id }</strong></p>
  
  <p>That route is defined as <code>Route::get('/admin/document/{document}', 'DocumentController@show');</code></p>
  
  <p>Where in the controller I pass the document to the view:</p>
  
  <pre><code>public function show(Document $document, Request $request)
  {
      // check to make sure user is an admin
      $request-&gt;user()-&gt;authorizeRoles('admin');
  
      $storagePath = Storage::disk('local')-&gt;getDriver()-&gt;getAdapter()-&gt;getPathPrefix();
  
      return view('admin.document', compact('document', 'storagePath'));
  }
  </code></pre>
  
  <p>On that page I would like to display the pdf document.</p>
  
  <p><strong>resources/views/admin/document.blade.php</strong></p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
  &lt;div class='container'&gt;
      &lt;div class='row'&gt;
          &lt;div class='col-sm-2'&gt;
              &lt;a href='/admin'&gt;&lt; Back to admin&lt;/a&gt;
          &lt;/div&gt;
          &lt;div class='col-sm-8'&gt;
              {{ $document }}
  
              &lt;embed src="{{ Storage::url($document-&gt;file_path) }}" style="width:600px; height:800px;" frameborder="0"&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  @endsection
  </code></pre>
  
  <p>I have tried using the <code>$storagePath</code> variable and <code>Storage</code> methods but cannot get the pdf file to display within the iframe.</p>
  
  <p>Using local file storage how would I display the file in the browser? Also, I've protected the route so that only admins can view the document's page but what is the best way to secure the path to the document itself?</p>