Upload_Validator
class Upload_Validator
Traits
Config options
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_file | 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 |
Properties
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. | |
array | $allowedExtensions |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
Return all errors that occurred while validating the temporary file.
Clear out all errors
Set information about temporary file produced by PHP.
Get maximum file size for all or specified file extension.
Set filesize maximums (in bytes or INI format).
No description
Limit allowed file extensions. Empty by default, allowing all extensions.
Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {@link $allowedMaxFileSize}
Determine if this file is valid but empty
Determines if the temporary file has a valid extension An empty string in the validation map indicates files without an extension.
Return the extension of the uploaded file, in lowercase Returns an empty string for files without an extension
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.
Check that a valid file was given for upload (ignores file size)
Check whether the file was fully uploaded
Details
in Injectable at line 26
static Injectable
create(array $args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
in Injectable at line 43
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
at line 70
array
getErrors()
Return all errors that occurred while validating the temporary file.
at line 78
clearErrors()
Clear out all errors
at line 87
setTmpFile(array $tmpFile)
Set information about temporary file produced by PHP.
at line 98
int
getAllowedMaxFileSize(string $ext = null)
Get maximum file size for all or specified file extension.
at line 142
setAllowedMaxFileSize(array|int $rules)
Set filesize maximums (in bytes or INI format).
Automatically converts extensions to lowercase for easier matching.
Example:
array('*' => 200, 'jpg' => 1000, '[doc]' => '5m')
at line 170
array
getAllowedExtensions()
at line 184
setAllowedExtensions(array $rules)
Limit allowed file extensions. Empty by default, allowing all extensions.
To allow files without an extension, use an empty string. See {@link File::$allowed_extensions} to get a good standard set of extensions that are typically not harmful in a webserver context. See {@link setAllowedMaxFileSize()} to limit file size by extension.
at line 205
boolean
isValidSize()
Determines if the bytesize of an uploaded file is valid - can be defined on an extension-by-extension basis in {@link $allowedMaxFileSize}
at line 222
bool
isFileEmpty()
Determine if this file is valid but empty
at line 236
boolean
isValidExtension()
Determines if the temporary file has a valid extension An empty string in the validation map indicates files without an extension.
at line 248
string
getFileExtension()
Return the extension of the uploaded file, in lowercase Returns an empty string for files without an extension
at line 266
boolean
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.
at line 323
bool
isValidUpload()
Check that a valid file was given for upload (ignores file size)
at line 349
bool
isCompleteUpload()
Check whether the file was fully uploaded