Beispiel #1
0
 public function testOk()
 {
     $validator = new Simple(10, array('image/png'));
     $file = new File();
     $file->size = 10;
     $file->type = 'image/png';
     $this->assertTrue($validator->validate($file, 10));
     $this->assertEmpty($file->error);
 }
Beispiel #2
0
 public function validate($tmp_name, File $file, $current_size)
 {
     //check extension
     $fileExtension = end(explode('.', $file->name));
     if (!in_array($fileExtension, $this->allowed_extensions)) {
         $file->error = $this->messages[self::UPLOAD_ERR_BAD_EXTENSION];
         return false;
     } else {
         //check myme-type & size
         return parent::validate($tmp_name, $file, $current_size);
     }
 }