← PHP / Laravel · Contents

PHP-091 / Beginner

No limits on upload size or count

A04:2021 Insecure Design · CWE-400 Uncontrolled Resource Consumption

Why is this a problem?

Large uploads exhaust disk space and memory.

How to fix it

php
$request->validate(['files' => 'array|max:5', 'files.*' => 'file|max:5120']);  // 5MB

Further reading