In laravel, I am making an application that uploads a file and the user can retrieve that same file.
But each time I click to upload I get this error.
FileNotFoundException in FilesystemAdapter.php line 91:
/storage/ap/payments/98AcresResort_25.pdf
my controller code is this:
$filePath = "/storage/ap/payments/".$payment->payment_image;
$file = storage::disk('public')->get($filePath);
my file is located at /public/storage/ap/payments/filename.pdf
I tried php artisan storage:link
Can anyone suggest any solution, please?
Since your file is located at this place
/your-app/public/storage/ap/payments/filename.pdfyou need to add a disk.In the file
config/filesystems.phpadd the disk
Then you can use it like this
It will look for the location
/your-app/public/storage/ap/payments/filename.pdf"But I suspect that your file
/public/storage/ap/payments/filename.pdfwas also in the/storagefolder and that you're working through a symlink. The correct ways would be to have app instead of ap and to use thepublicdisk like thisStorage::disk('public')->path('payments/filename.pdf')Even better, since it's a a payment, you probably don't want the file to be public and accessible to all. In that case you can use the disk
localand serve the file on request. But that's maybe more advanced stuff.