sfValidatorFile validates an uploaded file.
Method Summary
addMessage , addOption , addRequiredOption , asString , clean , configure , doClean , getCharset , getDefaultMessages , getDefaultOptions , getEmptyValue , getErrorCodes , getMessage , getMessages , getMessagesWithoutDefaults , getOption , getOptions , getOptionsWithoutDefaults , getRequiredOptions , hasOption , isEmpty , setCharset , setDefaultMessages , setDefaultOptions , setInvalidMessage , setMessage , setMessages , setOption , setOptions , setRequiredMessage , __construct
Method Details
-
configure ($options = array(), $messages = array())
Browse code
| $options |
An array of options
|
| $messages |
An array of error messages
|
Configures the current validator.
Available options: * max_size: The maximum file size
* mime_types: Allowed mime types array or category (available categories: web_images)
* mime_type_guessers: An array of mime type guesser PHP callables (must return the mime type or null)
* mime_categories: An array of mime type categories (web_images is defined by default)
* path: The path where to save the file - as used by the sfValidatedFile class (optional)
* validated_file_class: Name of the class that manages the cleaned uploaded file (optional) There are 3 built-in mime type guessers: * guessFromFileinfo: Uses the finfo_open() function (from the Fileinfo PECL extension)
* guessFromMimeContentType: Uses the mime_content_type() function (deprecated)
* guessFromFileBinary: Uses the file binary (only works on *nix system) Available error codes: * max_size * mime_types * partial * no_tmp_dir * cant_write * extension
-
This validator always returns a sfValidatedFile object.
The input value must be an array with the following keys: * tmp_name: The absolute temporary path to the file
* name: The original file name (optional)
* type: The file content type (optional)
* error: The error code (optional)
* size: The file size in bytes (optional)
-
(string) getMimeType ($file, $fallback)
Browse code
| $file |
The absolute path of a file
|
| $fallback |
The default mime type to return if not guessable
|
Returns the mime type of a file.
This methods call each mime_type_guessers option callables to guess the mime type.
returns The mime type of the file (fallback is returned if not guessable)
-
getMimeTypesFromCategory ($category)
Browse code
-
(string) guessFromFileBinary ($file)
Browse code
| $file |
The absolute path of a file
|
Guess the file mime type with the file binary (only available on *nix)
returns The mime type of the file (null if not guessable)
-
(string) guessFromFileinfo ($file)
Browse code
| $file |
The absolute path of a file
|
Guess the file mime type with PECL Fileinfo extension
returns The mime type of the file (null if not guessable)
-
(string) guessFromMimeContentType ($file)
Browse code
| $file |
The absolute path of a file
|
Guess the file mime type with mime_content_type function (deprecated)
returns The mime type of the file (null if not guessable)
-
|