Albert90's avatar

Uploaded .pdf file cannot be opened in a view

As the title says I have a problem with opening my uploaded file in my Laravel based program. In the specific view I managed to upload the .pdf file I've chosen in the HTML form and Laravel stores it properly in the /storage directory, right there where it belongs.

Than I did try to add a link in my blade view file to the uploaded PDF its file name I stored in an eloquent record with

'$data->file_name = $request->file('clients_papers')->hashName();'

, the name matches to the given hash name.

How can i create a link in my blade view to open my pdf file. (It is stored in storage/app/created_directory.)

0 likes
6 replies
Snapey's avatar

It needs to be in storage/app/public to be accessible to the outside world, and you need to have created a symlink using the php artisan command.

Alternatively create the symlink yourself to the right folder.

1 like
Albert90's avatar

I have done it with php artisan storage:link. The files were stored right in the storage/app/public. I tried to open it a simple way like this:

The result: Sorry, the page can not be found...

Albert90's avatar

This is the very simple way i wanted to open the saved pdf file:

<a href="storage/app/public/NABgjM7fIcnVIpihv6HTeP3mgq8AuwIezhmDyuXw.pdf">

Snapey's avatar

<a href="/storage/NABgjM7fIcnVIpihv6HTeP3mgq8AuwIezhmDyuXw.pdf">

Albert90's avatar

And that's it!!! Thank You very much!

Please or to participate in this conversation.