How do I block an upload greater than 2mb?
I'm capturing the file like this:
$imagem = $_FILES["imagem"];
How do I block an upload greater than 2mb?
I'm capturing the file like this:
$imagem = $_FILES["imagem"];
Each $ _FILES key has a size
key, which by default is measured in bytes. We can convert this way
for 2mb:
if($_FILES['imagem']['size'] > 2097152) {
echo 'não é permitido';
}
For 2gb:
if($_FILES['imagem']['size'] > 2147483648) {
echo 'não é permitido';
}
Note that for 2gb is a large file, you must have the correct settings on the server, php.ini:
post_max_size = 2048M
upload_max_filesize = 2048M