1<embed
2 src="{{ action('DocumentController@getDocument', ['id'=> $document->id]) }}"
3 style="width:600px; height:800px;"
4 frameborder="0"
5>
1public function getDocument($id)
2{
3 $document = Document::findOrFail($id);
4
5 $filePath = $document->file_path;
6
7 // file not found
8 if( ! Storage::exists($filePath) ) {
9 abort(404);
10 }
11
12 $pdfContent = Storage::get($filePath);
13
14 // for pdf, it will be 'application/pdf'
15 $type = Storage::mimeType($filePath);
16 $fileName = Storage::name($filePath);
17
18 return Response::make($pdfContent, 200, [
19 'Content-Type' => $type,
20 'Content-Disposition' => 'inline; filename="'.$fileName.'"'
21 ]);
22}