Path Traversal in PHP and Laravel: Safe File Paths
Never concatenate request input onto a filesystem path. Reject null bytes, backslashes and absolute paths, resolve the result with realpath(), and allow the file only when it stays inside a known base directory. realpath() returns false when the path does not exist, so new files need a parent-directory check.
