views:

41

answers:

1

Hello friends,

I´m trying to use the zend mime validator and I´m doing this:

$mime = array('image/jpeg','image/gif');
$valid = new Zend_Validate_File_MimeType($mime);
if ($valid->isValid($_FILES['file']['name']){
// do some stuff
}

But it not working, the documentation is weak, how can I use it??! THanks and best regard´s!

+1  A: 

Use $valid->getMessages() to find out what happened

if ($valid->isValid($_FILES['file']['name']){
// do some stuff
} else {
$messages = $valid->getMessages();
print_r($messages);
}
//do the normal stuff
Ashley
Should I use it with try catch? Thanks.
Rodrigo Ferrari
No, it's not an exception, an if else statement will do fine
Ashley
Ok, thanks, I will try it and see what´s happening. Thanks again.
Rodrigo Ferrari