symfony API

sfValidatedFile Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.4 API OpenSearch

Packages

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

sfValidatedFile represents a validated uploaded file.

Method Summary

  • string generateFilename()
    Generates a random filename for the current file.
  • string getExtension($default)
    Returns the file extension, based on the content type of the file.
  • string getExtensionFromType($type, $default)
    Returns the extension associated with the given content type.
  • string getOriginalExtension($default)
    Returns the original uploaded file name extension.
  • string getOriginalName()
    Returns the original file name.
  • string getPath()
    Returns the path to use when saving a file with a relative filename.
  • string getSavedName()
    Returns the path where the file has been saved
  • int getSize()
    Returns the size of the uploaded file.
  • string getTempName()
    Returns the absolute temporary path to the uploaded file.
  • string getType()
    Returns the file content type.
  • Boolean isSaved()
    Returns true if the file has already been saved.
  • string save($file, $fileMode, $create, $dirMode)
    Saves the uploaded file.
  • __construct($originalName, $type, $tempName, $size, $path)
    Constructor.
  • __toString()
    Returns the name of the saved file.

Method Details

  • (string) generateFilename () Browse code

    Generates a random filename for the current file.

    returns A random name to represent the current file

  • (string) getExtension ($default) Browse code

    $default The default extension to return if none was given

    Returns the file extension, based on the content type of the file.

    returns The extension (with the dot)

  • (string) getExtensionFromType ($type, $default) Browse code

    $type The content type
    $default The default extension to use

    Returns the extension associated with the given content type.

    returns The extension (with the dot)

  • (string) getOriginalExtension ($default) Browse code

    $default The default extension to return if none was given

    Returns the original uploaded file name extension.

    returns The extension of the uploaded name (with the dot)

  • (string) getOriginalName () Browse code

    Returns the original file name.

    returns The file name

  • (string) getPath () Browse code

    Returns the path to use when saving a file with a relative filename.

    returns The path to use when saving a file with a relative filename

  • (string) getSavedName () Browse code

    Returns the path where the file has been saved

    returns The path where the file has been saved

  • (int) getSize () Browse code

    Returns the size of the uploaded file.

    returns The file size

  • (string) getTempName () Browse code

    Returns the absolute temporary path to the uploaded file.

    returns The temporary path

  • (string) getType () Browse code

    Returns the file content type.

    returns The content type

  • (Boolean) isSaved () Browse code

    Returns true if the file has already been saved.

    returns true if the file has already been saved, false otherwise

  • (string) save ($file, $fileMode, $create, $dirMode) Browse code

    $file The file path to save the file
    $fileMode The octal mode to use for the new file
    $create Indicates that we should make the directory before moving the file
    $dirMode The octal mode to use when creating the directory

    Saves the uploaded file.


    This method can throw exceptions if there is a problem when saving the file.

    If you don't pass a file name, it will be generated by the generateFilename method.
    This will only work if you have passed a path when initializing this instance.

    returns The filename without the $this->path prefix

    throws Exception

  • __construct ($originalName, $type, $tempName, $size, $path) Browse code

    $originalName The original file name
    $type The file content type
    $tempName The absolute temporary path to the file
    $size The file size (in bytes)
    $path The path to save the file (optional).

    Constructor.

  • __toString () Browse code

    Returns the name of the saved file.