title: Error. Failed to load pdf document in laravel
body: <p>I want to load pdf file in html but i got an error.</p>
  
  <p>here is my function </p>
  
  <pre><code> public function getDocument($file){
        $filePath = 'app/final/attachments/AA-19-4-2019-18123/'.$file;
        $type = Storage::mimeType($filePath);
        $pdfContent = Storage::get($filePath);
  
        return Response::make($pdfContent, 200, [
           'Content-Type'        =&gt; $type,
           'Content-Disposition' =&gt; 'inline; filename="'.$file.'"'
        ]);
   }
  </code></pre>
  
  <p>here is my route</p>
  
  <pre><code> Route::get('/documents/pdf-document/{file}', 'inboxController@getDocument');
  </code></pre>
  
  <p>and here is my code in blade</p>
  
  <pre><code> &lt;embed src="{{ action('inboxController@getDocument', ['file'=&gt; basename($attach)]) }}" style="width:100%;height:auto;overflow: hidden;" frameborder="0" allowfullscreen&gt;
  </code></pre>
  
  <p>it seems like, the error is because of the filename of the file. When i changed it to asdf.pdf, it loaded the file, but when i change its filename i wont loaded anymore. Images doesnt have really a problem. only pdf files. Please help me</p>
  
  <p>edit</p>
  
  <p>when i tried to use this static code, then remove {file} from route and also in blade, then pdf will loaded. i cant figure it out why.</p>
  
  <pre><code> public function getDocument(){
        $filePath = 'app/final/attachments/AA-19-4-2019-18123/my.pdf';
        $type = Storage::mimeType($filePath);
        $pdfContent = Storage::get($filePath);
  
        return Response::make($pdfContent, 200, [
           'Content-Type'        =&gt; $type,
           'Content-Disposition' =&gt; 'inline; filename="'.$file.'"'
        ]);
   }
  </code></pre>