SilverStripe\Assets\Upload_Validator

Synopsis

class Upload_Validator {
}

Hierarchy

Uses

  • SilverStripe\Core\Injector\Injectable
  • SilverStripe\Core\Config\Configurable

Members

private

  • $default_max_file_size — array
    Contains a list of the max file sizes shared by all upload fields. This is then duplicated into the "allowedMaxFileSize" instance property on construct.
  • $use_is_uploaded_fileSilverStripe\Assets\bool
    Set to false to assume is_uploaded_file() is true, Set to true to actually call is_uploaded_file() Useful to use when testing uploads

protected

  • $errors
  • $tmpFile — array
    Information about the temporary file produced by the PHP-runtime.

public

  • $allowedExtensions — array
  • $allowedMaxFileSize — array
    Restrict filesize for either all filetypes or a specific extension, with extension-name as array-key and the size-restriction in bytes as array-value.

Methods

public

  • clearErrors() — Clear out all errors
  • getAllowedExtensions()
  • getAllowedMaxFileSize() — Get maximum file size for all or specified file extension.
  • getErrors() — Return all errors that occurred while validating the temporary file.
  • getFileExtension() — Return the extension of the uploaded file, in lowercase Returns an empty string for files without an extension
  • getLargestAllowedMaxFileSize() — Returns the largest maximum filesize allowed across all extensions
  • isCompleteUpload() — Check whether the file was fully uploaded
  • isFileEmpty() — Determine if this file is valid but empty
  • isValidExtension() — Determines if the temporary file has a valid extension An empty string in the validation map indicates files without an extension.
  • isValidSize() — Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {@link $allowedMaxFileSize}
  • isValidUpload() — Check that a valid file was given for upload (ignores file size)
  • setAllowedExtensions() — Limit allowed file extensions. Empty by default, allowing all extensions.
  • setAllowedMaxFileSize() — Set filesize maximums (in bytes or INI format).
  • setTmpFile() — Set information about temporary file produced by PHP.
  • validate() — Run through the rules for this validator checking against the temporary file set by {@link setTmpFile()} to see if the file is deemed valid or not.