PHP-014 / Beginner
Trusting only uploaded file extension or MIME type
Why is this a problem?
Client-supplied Content-Type and extensions can be forged; bypasses such as .php.jpg also exist.
How to fix it
php
$request->validate(['img' => 'required|image|mimes:jpg,png|max:2048']);
$path = $request->file('img')->store('avatars', 'private'); // Random filename, private disk