Safe File Uploads in PHP and Laravel: Validation, Storage and Serving
Treat the client filename, extension and Content-Type as untrusted, detect the type from file contents, store under a generated name on a non-public disk, and never let the web server execute an upload as PHP.
