Class UploadedFile
A file uploaded through a form.
-
SplFileInfo
-
Symfony\Component\HttpFoundation\File\File
-
Symfony\Component\HttpFoundation\File\UploadedFile
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
string $path The full temporary path to the file
- $originalName
string $originalName The original file name
- $mimeType
string $mimeType The type of the file as provided by PHP
- $size
integer $size The file size
- $error
integer $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants)
- $test
Boolean $test Whether the test mode is active
Throws
Api
Overrides
|
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
is 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 is 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.
It is extracted from the request from which the file has been uploaded. Then
is should not be considered as a safe value.
Returns
string|null The mime type
Api
|
public
integer|null
|
#
getClientSize( )
Returns the file size.
It is extracted from the request from which the file has been uploaded. Then
is 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 no error occurred during uploading
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
string $directory The destination folder
- $name
string $name The new file name
Returns
Throws
Api
Overrides
|
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
|
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()
|
Properties summary
private
Boolean
|
$test
|
false |
#
Whether the test mode is activated.
Whether the test mode is activated.
Local files are used in test mode hence the code should not enforce HTTP
uploads.
|
private
string
|
$originalName
|
|
#
The original name of the uploaded file.
The original name of the uploaded file.
|
private
string
|
$mimeType
|
|
#
The mime type provided by the uploader.
The mime type provided by the uploader.
|
private
string
|
$size
|
|
#
The file size provided by the uploader.
The file size provided by the uploader.
|
private
integer
|
$error
|
|
#
The UPLOAD_ERR_XXX constant provided by the uploader.
The UPLOAD_ERR_XXX constant provided by the uploader.
|