Necesito validar que los archivos que estoy por subir al servidor sean imagenes.
$types = array(); contiene los tipos permitidos.
Código:
Código PHP:
Ver original 'image/jpeg',
'image/gif',
//'image/png',
'image/pjpeg',
'image/x-png'
);
//Parametro $filetypes
array( (int
) 0 => array( 'name' => '1.jpg', 'type' => 'image/jpeg', 'tmp_name' => '/tmp/phpwl10Kv', 'error' => (int
) 0, 'size' => (int
) 40583 ), (int
) 1 => array( 'name' => 'lancha.png', 'type' => 'image/png', 'tmp_name' => '/tmp/phpdWvZoS', 'error' => (int
) 0, 'size' => (int
) 206569 ) )
function check($filetypes)
{
$error = false;
foreach (types as $allow) {
foreach ($filetypes as $filetype) {
if ($filetype['type'] == $allow) {
$error = true;
}
}
}
if ($error == true) {
return true;
}
}
Necesito comprobar el tipo de archivo de cada uno de las imagenes que subo con los tipos permitidos ($types).
Este código que les muetro sólo valida una sóla imagen y se sale del bucle.