/** * @see \wcf\system\upload\IUploadFileValidationStrategy::validate() */ public function validate(UploadFile $uploadFile) { if ($uploadFile->getErrorCode() != 0) { $uploadFile->setValidationErrorType('uploadFailed'); return false; } if ($uploadFile->getFilesize() > $this->maxFilesize) { $uploadFile->setValidationErrorType('tooLarge'); return false; } if (!preg_match($this->fileExtensionRegex, mb_strtolower($uploadFile->getFilename()))) { $uploadFile->setValidationErrorType('invalidExtension'); return false; } return true; }
/** * @see wcf\system\upload\IUploadFileValidationStrategy::validate() */ public function validate(UploadFile $uploadFile) { if ($uploadFile->getErrorCode() != 0) { $uploadFile->setValidationErrorType('uploadFailed'); return false; } if ($uploadFile->getFilesize() > $this->maxFilesize) { $uploadFile->setValidationErrorType('tooLarge'); return false; } if (!in_array($uploadFile->getFileExtension(), $this->fileExtensions)) { $uploadFile->setValidationErrorType('invalidExtension'); return false; } return true; }