Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • File
  • UploadedFile
  • Overview
  • Namespace
  • Class
  • Tree

Class UploadedFile

A file uploaded through a form.

SplFileInfo
Extended by Symfony\Component\HttpFoundation\File\File
Extended by Symfony\Component\HttpFoundation\File\UploadedFile
Namespace: Symfony\Component\HttpFoundation\File
Author: Bernhard Schussek bschussek@gmail.com
Author: Florian Eckerstorfer florian@eckerstorfer.org
Author: Fabien Potencier fabien@symfony.com
Api
Located at File/UploadedFile.php
Methods summary
public
# __construct( string $path, string $originalName, string $mimeType = null, integer $size = null, integer $error = null, boolean $test = false )

Accepts the information of the uploaded file as provided by the PHP global $_FILES.

Accepts the information of the uploaded file as provided by the PHP global $_FILES.

The file object is only created when the uploaded file is valid (i.e. when the isValid() method returns true). Otherwise the only methods that could be called on an UploadedFile instance are: * getClientOriginalName, * getClientMimeType, * isValid, * getError.

Calling any other method on an non-valid instance will cause an unpredictable result.

Parameters

$path
The full temporary path to the file
$originalName
The original file name
$mimeType
The type of the file as provided by PHP
$size
The file size
$error
The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
$test
Whether the test mode is active

Throws

Symfony\Component\HttpFoundation\File\Exception\FileException
If file_uploads is disabled
Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
If the file does not exist

Api

Overrides

Symfony\Component\HttpFoundation\File\File::__construct()
public string|null
# getClientOriginalName( )

Returns the original file name.

Returns the original file name.

It is extracted from the request from which the file has been uploaded. Then it should not be considered as a safe value.

Returns

string|null
The original name

Api

public string
# getClientOriginalExtension( )

Returns the original file extension.

Returns the original file extension.

It is extracted from the original file name that was uploaded. Then it should not be considered as a safe value.

Returns

string
The extension
public string|null
# getClientMimeType( )

Returns the file mime type.

Returns the file mime type.

The client mime type is extracted from the request from which the file was uploaded, so it should not be considered as a safe value.

For a trusted mime type, use getMimeType() instead (which guesses the mime type based on the file content).

Returns

string|null
The mime type

See

Symfony\Component\HttpFoundation\File\File::getMimeType()

Api

public string|null
# guessClientExtension( )

Returns the extension based on the client mime type.

Returns the extension based on the client mime type.

If the mime type is unknown, returns null.

This method uses the mime type as guessed by getClientMimeType() to guess the file extension. As such, the extension returned by this method cannot be trusted.

For a trusted extension, use guessExtension() instead (which guesses the extension based on the guessed mime type for the file).

Returns

string|null
The guessed extension or null if it cannot be guessed

See

Symfony\Component\HttpFoundation\File\File::guessExtension()
Symfony\Component\HttpFoundation\File\UploadedFile::getClientMimeType()
public integer|null
# getClientSize( )

Returns the file size.

Returns the file size.

It is extracted from the request from which the file has been uploaded. Then it should not be considered as a safe value.

Returns

integer|null
The file size

Api

public integer
# getError( )

Returns the upload error.

Returns the upload error.

If the upload was successful, the constant UPLOAD_ERR_OK is returned. Otherwise one of the other UPLOAD_ERR_XXX constants is returned.

Returns

integer
The upload error

Api

public boolean
# isValid( )

Returns whether the file was uploaded successfully.

Returns whether the file was uploaded successfully.

Returns

boolean
True if the file has been uploaded with HTTP and no error occurred.

Api

public Symfony\Component\HttpFoundation\File\File
# move( string $directory, string $name = null )

Moves the file to a new location.

Moves the file to a new location.

Parameters

$directory
The destination folder
$name
The new file name

Returns

Symfony\Component\HttpFoundation\File\File
A File object representing the new file

Throws

Symfony\Component\HttpFoundation\File\Exception\FileException
if, for any reason, the file could not have been moved

Api

Overrides

Symfony\Component\HttpFoundation\File\File::move()
public static integer
# getMaxFilesize( )

Returns the maximum size of an uploaded file as configured in php.ini.

Returns the maximum size of an uploaded file as configured in php.ini.

Returns

integer
The maximum size of an uploaded file in bytes
public string
# getErrorMessage( )

Returns an informative upload error message.

Returns an informative upload error message.

Returns

string
The error message regarding the specified error code
Methods inherited from Symfony\Component\HttpFoundation\File\File
getExtension(), getMimeType(), getName(), getTargetFile(), guessExtension()
Methods inherited from SplFileInfo
__toString(), _bad_state_ex(), getATime(), getBasename(), getCTime(), getFileInfo(), getFilename(), getGroup(), getInode(), getLinkTarget(), getMTime(), getOwner(), getPath(), getPathInfo(), getPathname(), getPerms(), getRealPath(), getSize(), getType(), isDir(), isExecutable(), isFile(), isLink(), isReadable(), isWritable(), openFile(), setFileClass(), setInfoClass()
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen