Open Journal Systems  3.3.0
Symfony\Component\HttpFoundation\File\UploadedFile Class Reference
Inheritance diagram for Symfony\Component\HttpFoundation\File\UploadedFile:
Symfony\Component\HttpFoundation\File\File

Public Member Functions

 __construct ($path, $originalName, $mimeType=null, $size=null, $error=null, $test=false)
 
 __construct (string $path, string $originalName, string $mimeType=null, int $error=null, $test=false)
 
 getClientMimeType ()
 
 getClientMimeType ()
 
 getClientOriginalExtension ()
 
 getClientOriginalExtension ()
 
 getClientOriginalName ()
 
 getClientOriginalName ()
 
 getClientSize ()
 
 getClientSize ()
 
 getError ()
 
 getError ()
 
 getErrorMessage ()
 
 getErrorMessage ()
 
 guessClientExtension ()
 
 guessClientExtension ()
 
 isValid ()
 
 isValid ()
 
 move ($directory, $name=null)
 
 move ($directory, $name=null)
 
- Public Member Functions inherited from Symfony\Component\HttpFoundation\File\File
 __construct ($path, $checkPath=true)
 
 __construct (string $path, bool $checkPath=true)
 
 getMimeType ()
 
 getMimeType ()
 
 guessExtension ()
 
 guessExtension ()
 

Static Public Member Functions

static getMaxFilesize ()
 
static getMaxFilesize ()
 

Additional Inherited Members

- Protected Member Functions inherited from Symfony\Component\HttpFoundation\File\File
 getName ($name)
 
 getName ($name)
 
 getTargetFile ($directory, $name=null)
 
 getTargetFile ($directory, $name=null)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::__construct (   $path,
  $originalName,
  $mimeType = null,
  $size = null,
  $error = null,
  $test = false 
)

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
string$pathThe full temporary path to the file
string$originalNameThe original file name
string | null$mimeTypeThe type of the file as provided by PHP; null defaults to application/octet-stream
int | null$sizeThe file size
int | null$errorThe error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
bool$testWhether the test mode is active
Exceptions
FileExceptionIf file_uploads is disabled
FileNotFoundExceptionIf the file does not exist

Definition at line 103 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\File\getName().

◆ __construct() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::__construct ( string  $path,
string  $originalName,
string  $mimeType = null,
int  $error = null,
  $test = false 
)

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
string$pathThe full temporary path to the file
string$originalNameThe original file name of the uploaded file
string | null$mimeTypeThe type of the file as provided by PHP; null defaults to application/octet-stream
int | null$errorThe error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
bool$testWhether the test mode is active Local files are used in test mode hence the code should not enforce HTTP uploads
Exceptions
FileExceptionIf file_uploads is disabled
FileNotFoundExceptionIf the file does not exist

Definition at line 63 of file vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\File\getName().

Member Function Documentation

◆ getClientMimeType() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientMimeType ( )

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 The mime type
See also
getMimeType()

Definition at line 119 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getClientMimeType() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientMimeType ( )

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 also
getMimeType()

Definition at line 153 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

Referenced by Symfony\Component\HttpFoundation\File\UploadedFile\guessClientExtension().

◆ getClientOriginalExtension() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientOriginalExtension ( )

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

Definition at line 101 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getClientOriginalExtension() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientOriginalExtension ( )

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

Definition at line 135 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getClientOriginalName() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientOriginalName ( )

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 The original name

Definition at line 88 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getClientOriginalName() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientOriginalName ( )

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

Definition at line 122 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

Referenced by Symfony\Component\HttpFoundation\File\UploadedFile\getErrorMessage().

◆ getClientSize() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientSize ( )

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.

Deprecated:
since Symfony 4.1, use getSize() instead.
Returns
int|null The file sizes

Definition at line 156 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getClientSize() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getClientSize ( )

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
int|null The file size

Definition at line 191 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getError() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getError ( )

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
int The upload error

Definition at line 171 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getError() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getError ( )

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
int The upload error

Definition at line 204 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getErrorMessage() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getErrorMessage ( )

Returns an informative upload error message.

Returns
string The error message regarding the specified error code

Definition at line 290 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getClientOriginalName(), and Symfony\Component\HttpFoundation\File\UploadedFile\getMaxFilesize().

Referenced by Symfony\Component\HttpFoundation\File\UploadedFile\move().

◆ getErrorMessage() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::getErrorMessage ( )

Returns an informative upload error message.

Returns
string The error message regarding the specified error code

Definition at line 290 of file vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getClientOriginalName(), and Symfony\Component\HttpFoundation\File\UploadedFile\getMaxFilesize().

◆ getMaxFilesize() [1/2]

static Symfony\Component\HttpFoundation\File\UploadedFile::getMaxFilesize ( )
static

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

Returns
int The maximum size of an uploaded file in bytes

Definition at line 244 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ getMaxFilesize() [2/2]

static Symfony\Component\HttpFoundation\File\UploadedFile::getMaxFilesize ( )
static

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

Returns
int The maximum size of an uploaded file in bytes

Definition at line 258 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

Referenced by Symfony\Component\HttpFoundation\File\UploadedFile\getErrorMessage().

◆ guessClientExtension() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::guessClientExtension ( )

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 also
guessExtension()
getClientMimeType()

Definition at line 141 of file vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getClientMimeType(), and Symfony\Component\Mime\MimeTypes\getDefault().

◆ guessClientExtension() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::guessClientExtension ( )

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 also
guessExtension()
getClientMimeType()

Definition at line 175 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getClientMimeType(), and Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser\getInstance().

◆ isValid() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::isValid ( )

Returns whether the file was uploaded successfully.

Returns
bool True if the file has been uploaded with HTTP and no error occurred

Definition at line 181 of file vendor/symfony/http-foundation/File/UploadedFile.php.

◆ isValid() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::isValid ( )

Returns whether the file was uploaded successfully.

Returns
bool True if the file has been uploaded with HTTP and no error occurred

Definition at line 214 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

Referenced by Symfony\Component\HttpFoundation\File\UploadedFile\move().

◆ move() [1/2]

Symfony\Component\HttpFoundation\File\UploadedFile::move (   $directory,
  $name = null 
)

Moves the file to a new location.

Parameters
string$directoryThe destination folder
string$nameThe new file name
Returns
File A File object representing the new file
Exceptions
FileExceptionif, for any reason, the file could not have been moved

Reimplemented from Symfony\Component\HttpFoundation\File\File.

Definition at line 198 of file vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getErrorMessage(), Symfony\Component\HttpFoundation\File\File\getTargetFile(), and Symfony\Component\HttpFoundation\File\UploadedFile\isValid().

◆ move() [2/2]

Symfony\Component\HttpFoundation\File\UploadedFile::move (   $directory,
  $name = null 
)

Moves the file to a new location.

Parameters
string$directoryThe destination folder
string$nameThe new file name
Returns
File A File object representing the new file
Exceptions
FileExceptionif, for any reason, the file could not have been moved

Reimplemented from Symfony\Component\HttpFoundation\File\File.

Definition at line 231 of file lib/vendor/symfony/http-foundation/File/UploadedFile.php.

References Symfony\Component\HttpFoundation\File\UploadedFile\getErrorMessage(), Symfony\Component\HttpFoundation\File\File\getTargetFile(), and Symfony\Component\HttpFoundation\File\UploadedFile\isValid().


The documentation for this class was generated from the following file: