Example #1
0
 public function executeValidations()
 {
     if ($this->hasPostValue()) {
         // check file size
         if ($this->maxFileSize) {
             $this->errors[] = t('The file size exceeds max of ' . \Meta\Core\File::prettySize($this->maxFileSize));
         }
         // check has extension
         if (!$this->getExtension()) {
             $this->errors[] = t("The file name doesn't contain an valid extension");
         }
         // check allowed extensions
         if ($this->allowedExtensions) {
             $list = explode(',', array_map('trim', $this->allowedExtensions));
             if (!in_array($this->getExtension(), $list)) {
                 $this->errors[] = t('Invalid file extension');
             }
         }
     }
     parent::executeValidations();
 }