I want to embed a PDF file into a modal blade view. The disk is not public (because it shouldn't be) and with a logged in user, I get the 404 not found
message.
Inside config/filesystems.php I got:
<?php
'disks' => [
'custom' => [
'driver' => 'local',
'root' => storage_path('app/custom'),
],
Inside my blade view I already tested successfully
<iframe src="https://www.inkwelleditorial.com/pdfSample.pdf" width="100%" height="300"></iframe>
However, when I try:
<iframe src="{{ storage_path('app/custom/myFile.pdf')}}" width="100%" height="300"></iframe>
I get
404 NOT FOUND
I have made sure the file does exist:
dd(Storage::disk('custom')->path('myFile.pdf'))
=> shows absolute path correctly
dd(Storage::disk('custom')->exists('myFile.pdf'))
=> returns true.
How do I fix this?
First,you must know that
storage_path()
is a private path. if you want show storage file on web, you can see the config fileconfig/filesystems.php
run this command:
php artisan storage:link
, then go topublic
directory,you can see the soft link directory on thepublic
directory.Then you can use the url on webpage like this
<ifram src="/storage/app/custom/xxx.pdf" ></iframe>