Version: current

# Class Upload_Validator

Package: sapphire\filesystem
Located at sapphire/filesystem/Upload.php

## Methods summary

`public array` | # `getErrors( )` Return all errors that occurred while validating the temporary file. Return all errors that occurred while validating the temporary file. #### Returns `array` array
`public` | # `setTmpFile( array $tmpFile )` Set information about temporary file produced by PHP. Set information about temporary file produced by PHP. #### Parameters $tmpFile array $tmpFile
`public integer` | # `getAllowedMaxFileSize( string $ext = null )` Get maximum file size for all or specified file extension. Get maximum file size for all or specified file extension. #### Parameters $ext string $ext #### Returns `integer` Filesize in bytes
`public` | # `setAllowedMaxFileSize( array|integer $rules )` Set filesize maximums (in bytes). Automatically converts extensions to lowercase for easier matching. Set filesize maximums (in bytes). Automatically converts extensions to lowercase for easier matching. Example:
    array('*' => 200, 'jpg' => 1000)
#### Parameters $rules array|int $rules
`public array` | # `getAllowedExtensions( )` #### Returns `array` array
`public` | # `setAllowedExtensions( array $rules )` #### Parameters $rules array $rules
`public boolean` | # `isValidSize( )` Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {$allowedMaxFileSize} Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {$allowedMaxFileSize} #### Returns `boolean` boolean
`public boolean` | # `isValidExtension( )` Determines if the temporary file has a valid extension An empty string in the validation map indicates files without an extension. Determines if the temporary file has a valid extension An empty string in the validation map indicates files without an extension. #### Returns `boolean` boolean
`public boolean` | # `validate( )` Run through the rules for this validator checking against the temporary file set by `Upload_Validator::setTmpFile()` to see if the file is deemed valid or not. Run through the rules for this validator checking against the temporary file set by `Upload_Validator::setTmpFile()` to see if the file is deemed valid or not. #### Returns `boolean` boolean

### Magic methods summary

## Properties summary

`protected array` | $tmpFile | # Information about the temporary file produced by the PHP-runtime. Information about the temporary file produced by the PHP-runtime.
`protected array` | $errors | #
`public array` | $allowedMaxFileSize | # 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. 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.
`public array` | $allowedExtensions | # Collection of extensions. Extension-names are treated case-insensitive. Example:
    array("jpg","GIF")
Collection of extensions. Extension-names are treated case-insensitive. Example:
    array("jpg","GIF")

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -