0
Assuming there is a single array in the variable $_FILES
, the code below limits the upload size of a file:
if(empty($_FILES) && empty($_POST)
&& isset($_SERVER['REQUEST_METHOD'])
&& strtolower($_SERVER['REQUEST_METHOD']) == 'post'){ //pega o erro de tamanho maximo excedido
$postMax = ini_get('post_max_size'); //pega limite máximo
echo "Arquivo enviado excede: $postMax"; // exibe o erro
}
else {// continua com o processamento da página
echo "<pre>";
print_r($_FILES);
echo "<pre/>";
}
However, I have more than one array of the type file
, that is to say: $_FILES['logotipo']
and $_FILES['certificado']
. How would you adjust the response, or do this limitation individually for each file?
Reference: Limit upload size with PHP
If I’m not mistaken, put yourself
ini_get('post_max_size');
at the top of the file, he picks it up for everyone... I’m not sure– MagicHat
on the Soe: (English) https://stackoverflow.com/a/6576751/6510304
– Don't Panic
Each item of the array
file
will have the field["size"]=> int()
. What you need would be to validate in different ways for the$_FILES['logotipo']
and["size"]=> int(76928)
?– DNick
Hello @Dnick, the point is that the field
size
will only be filled in if the file does not exceed the limit, and I do not want to have to configure the php.ini for that reason.– lucasbento
Hello @Everson, falls in the same case and Dnick’s suggestion.
– lucasbento
@Magichat, but what would he have to do after that? Yeah, he just took the amount 8 M, and the limit is just 2 M and the file I’m going through is 2.5M (which already makes it
size
is set to zero).– lucasbento