protected function setImportedValue($value) { if ($value) { try { $size = getimagesize($value['tmp_name']); if ($size && $size[0] && $size[1] && in_array($size[2], $this->allowedImageTypes)) { if ($this->minWidth && $this->minWidth > $size[0] || $this->minHeight && $this->minHeight > $size[1]) { $this->setError(new FileFormControlError(FileFormControlError::TOO_SMALL)); return; } parent::setImportedValue($value); } else { throw new Exception(); } } catch (Exception $e) { $this->setError(new FileFormControlError(FileFormControlError::DISALLOWED_FILE_TYPE)); } } }
/** * @return FileFormControl */ static function file($name, $label) { return FileFormControl::create($name, $label); }