4
I’m trying to compare the extension of a file, but the same is failing I created a variable with the allowed extensions and I try to compare with the one being sent.
// Lista de tipos de arquivos permitidos
$tiposPermitidos = array('gif', 'jpeg', 'jpeg', 'png');
$infos = pathinfo($rowData['imagem']);
$arqType = $infos['extension'];
if (in_array($arqType, $tiposPermitidos)) {
echo 'O tipo de arquivo enviado é inválido, permitido somente imagens';
}
Running a var_dump($infos);
get the following result:
array(4) { ["dirname"]=> string(9) "../banner" ["basename"]=> string(9) "10889.php" ["extension"]=> string(3) "php" ["filename"]=> string(5) "10889" }
Have you checked what’s on
$infos
? Give avar_dump($infos)
and include the result in the question.– bfavaretto
The condition is changed, he’s getting into the
if
with valid types, not invalid ones, try:if (! in_array($arqType, $tiposPermitidos))
– gmsantos
Thanks @gmsantos and bfvaretto for the excellent tips.
– adventistapr