symfony API

sfValidatorFile Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.3 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.3 version. Switch to:

sfValidatorFile validates an uploaded file.

Inheritence

sfValidatorFile  <  sfValidatorBase

Method Summary

Methods inherited from sfValidatorBase

addMessage , addOption , addRequiredOption , asString , clean , configure , doClean , getCharset , getDefaultMessages , getDefaultOptions , getEmptyValue , getErrorCodes , getMessage , getMessages , getMessagesWithoutDefaults , getOption , getOptions , getOptionsWithoutDefaults , getRequiredOptions , hasOption , isEmpty , setCharset , setDefaultMessage , setDefaultMessages , setDefaultOptions , setInvalidMessage , setMessage , setMessages , setOption , setOptions , setRequiredMessage , __construct

Method Details

  • configure ($options, $messages) 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 in bytes (cannot exceed upload_max_filesize in php.ini)
    * 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

  • doClean () Browse code

    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.

    This method always returns a lower-cased string as mime types are case-insensitive
    as per the RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7).

    returns The mime type of the file (fallback is returned if not guessable)

  • getMimeTypesFromCategory () 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)

  • isEmpty () Browse code

    @see sfValidatorBase