FileUpload working perfectly locally but in production server throws 404 only when retrieving file
Hello.
I have this code:
And in config\filesystems.php disks:
And locally everything works fine. It uploads the file to storage\app\public\upload\1 folder, and in production it works too.
But, the problem comes when I want to "look at" the file. I have the ->openable() to let user open the PDF file. The links are:
LOCALLY:
http://127.0.0.1:8000/storage/upload/1/FileName.pdf
and it works perfectly.
IN PRODUCTION SERVER:
https://apps.geslem.com/storage/upload/1/FileName.pdf
and it THROWS A 404 NOT FOUND when trying to OPEN or DOWNLOAD the file.
I am using Forge to deploy, the storage:link is created (in fact, the uploads works correctly).
I have tried many thing with no success.
Any ideas, please, of what I am doing wrong?
Tks.
Solution:Jump to solution
Solved. You were right. Symlink was "broken" or something strange.
I deleted the storage folder and generate symlink again and solved....
3 Replies
Your symlink is probably wrong on the server.
Have you tried using
disk('public')->directory('upload')
with the default public disk configuration (ie: without adding /upload in the filesystems.php config)Same result.
I have changed what you mention, have tested locally and OK but again problems in the server. Upload is Ok, but open or download 404 NOT FOUND
Solution
Solved. You were right. Symlink was "broken" or something strange.
I deleted the storage folder and generate symlink again and solved.