-1

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!

leppie
  • 115,091
  • 17
  • 196
  • 297
digoferra
  • 1,001
  • 3
  • 17
  • 33
  • Can you define not working? Throws exception? Script dies? Kittens get killed? :) – Iznogood Aug 21 '10 at 02:00
  • 1
    Right it shoudl work with just the file name. Are you sure the file is uploaded ok? If you var_dump $_FILE do you get something? – Iznogood Aug 21 '10 at 02:06
  • I posted like this because I thought should use Zend_File or something similar to It. It´s correct, the form has enctype multipart and I just can´t do the validation. Should I use name ou type for the $_FILES variable?? Thanks. – digoferra Aug 24 '10 at 16:56

1 Answers1

1

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
  • 5,939
  • 9
  • 39
  • 82