Files in a Laravel application.
WHAT THE FRAMEWORK PROVIDES
A storage abstraction with configurable locations.
WHAT TO CONFIGURE
Where files go: a local directory, or an external service.
WHAT TO VALIDATE
That a file was uploaded Size Type, by content Dimensions, for images
WHAT TO NEVER TRUST
The supplied filename or declared type.
WHAT TO DO
Generate your own name, keeping the original as a label.
WHERE TO STORE
Outside the publicly served directory, by default.
HOW TO SERVE THEM
Through a route that checks entitlement, or via a public link where the file is genuinely public.
WHAT THE PUBLIC LINK REQUIRES
A symbolic link from the public directory to storage.
WHAT THAT MEANS ON SHARED HOSTING
The link must be created, and it must survive deployment.
WHAT TO CHECK
That the link exists after every deployment.
WHAT TO BE CAREFUL WITH
Disk space, which uploads consume steadily Orphaned files, when records are deleted
WHAT TO IMPLEMENT
Cleanup of files whose records no longer exist.