Class UploadedFile
- GuzzleHttp\Psr7\UploadedFile implements Psr\Http\Message\UploadedFileInterface
- Namespace: GuzzleHttp\Psr7
- Located at UploadedFile.php
Value object representing a file uploaded through an HTTP request.
Instances of this interface are considered immutable; all methods that might change state MUST be implemented such that they retain the internal state of the current instance and return an instance that contains the changed state.
Methods Summary
- __construct ( StreamInterface|string|resource $streamOrFile, int $size, int $errorStatus, string|null $clientFilename = null, string|null $clientMediaType = null )
- isMoved ( )
-
getStream ( )
Retrieve a stream representing the uploaded file.
-
moveTo ( string $targetPath )
Move the uploaded file to a new location.
-
getSize ( )
Retrieve the file size.
-
getError ( )
Retrieve the error associated with the uploaded file.
-
getClientFilename ( )
Retrieve the filename sent by the client.
-
getClientMediaType ( )
Retrieve the media type sent by the client.
Methods Details
__construct (
Psr\Http\Message\StreamInterface
|string|resource
$streamOrFile,
integer
$size,
integer
$errorStatus,
string|null
$clientFilename = null,
string|null
$clientMediaType = null
)
Parameters
Psr\Http\Message\StreamInterface |string|resource |
$streamOrFile | |
integer | $size | |
integer | $errorStatus | |
string|null | $clientFilename = null | |
string|null | $clientMediaType = null |
boolean isMoved ( )
Returns
boolean |
Psr\Http\Message\StreamInterface
getStream (
)
Retrieve a stream representing the uploaded file.
Returns
Psr\Http\Message\StreamInterface Stream representation of the uploaded file. |
Exceptions
RuntimeException if the upload was not successful. |
Implementation of
moveTo ( string $targetPath )
Move the uploaded file to a new location.
Parameters
string | $targetPath | Path to which to move the uploaded file. |
Exceptions
RuntimeException if the upload was not successful. |
InvalidArgumentException if the $path specified is invalid. |
RuntimeException on any error during the move operation, or on the second or subsequent call to the method. |
See
http://php.net/move_uploaded_file
Implementation of
integer|null getSize ( )
Retrieve the file size.
Returns
integer|null The file size in bytes or null if unknown. |
Implementation of
integer getError ( )
Retrieve the error associated with the uploaded file.
Returns
integer One of PHP's UPLOAD_ERR_XXX constants. |
See
Implementation of
string|null getClientFilename ( )
Retrieve the filename sent by the client.
Returns
string|null The filename sent by the client or null if none was provided. |
Implementation of
string|null getClientMediaType ( )
Retrieve the media type sent by the client.
Returns
string|null The media type sent by the client or null if none was provided. |