ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Represents Uploaded Files. More...
Public Member Functions | |
__construct ($file, $name=null, $type=null, $size=null, $error=UPLOAD_ERR_OK, $sapi=false) | |
Construct a new UploadedFile instance. More... | |
getStream () | |
Retrieve a stream representing the uploaded file. More... | |
moveTo ($targetPath) | |
Move the uploaded file to a new location. More... | |
getError () | |
Retrieve the error associated with the uploaded file. More... | |
getClientFilename () | |
Retrieve the filename sent by the client. More... | |
getClientMediaType () | |
Retrieve the media type sent by the client. More... | |
getSize () | |
Retrieve the file size. More... | |
Static Public Member Functions | |
static | createFromEnvironment (Environment $env) |
Create a normalized tree of UploadedFile instances from the Environment. More... | |
Data Fields | |
$file | |
Protected Attributes | |
$name | |
$type | |
$size | |
$error = UPLOAD_ERR_OK | |
$sapi = false | |
$stream | |
$moved = false | |
Static Private Member Functions | |
static | parseUploadedFiles (array $uploadedFiles) |
Parse a non-normalized, i.e. More... | |
Represents Uploaded Files.
It manages and normalizes uploaded files according to the PSR-7 standard.
https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php
Definition at line 24 of file UploadedFile.php.
Slim\Http\UploadedFile::__construct | ( | $file, | |
$name = null , |
|||
$type = null , |
|||
$size = null , |
|||
$error = UPLOAD_ERR_OK , |
|||
$sapi = false |
|||
) |
Construct a new UploadedFile instance.
string | $file | The full path to the uploaded file provided by the client. |
string | null | $name | The file name. |
string | null | $type | The file media type. |
int | null | $size | The file size in bytes. |
int | $error | The UPLOAD_ERR_XXX code representing the status of the upload. |
bool | $sapi | Indicates if the upload is in a SAPI environment. |
Definition at line 151 of file UploadedFile.php.
References Slim\Http\UploadedFile\$error, Slim\Http\UploadedFile\$file, Slim\Http\UploadedFile\$name, Slim\Http\UploadedFile\$sapi, Slim\Http\UploadedFile\$size, Slim\Http\UploadedFile\$type, file, and size.
|
static |
Create a normalized tree of UploadedFile instances from the Environment.
Environment | $env | The environment |
Definition at line 84 of file UploadedFile.php.
References Slim\Collection\has().
Referenced by Slim\Http\Request\createFromEnvironment().
Slim\Http\UploadedFile::getClientFilename | ( | ) |
Retrieve the filename sent by the client.
Do not trust the value returned by this method. A client could send a malicious filename with the intention to corrupt or hack your application.
Implementations SHOULD return the value stored in the "name" key of the file in the $_FILES array.
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 291 of file UploadedFile.php.
References Slim\Http\UploadedFile\$name.
Slim\Http\UploadedFile::getClientMediaType | ( | ) |
Retrieve the media type sent by the client.
Do not trust the value returned by this method. A client could send a malicious media type with the intention to corrupt or hack your application.
Implementations SHOULD return the value stored in the "type" key of the file in the $_FILES array.
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 309 of file UploadedFile.php.
References Slim\Http\UploadedFile\$type.
Slim\Http\UploadedFile::getError | ( | ) |
Retrieve the error associated with the uploaded file.
The return value MUST be one of PHP's UPLOAD_ERR_XXX constants.
If the file was uploaded successfully, this method MUST return UPLOAD_ERR_OK.
Implementations SHOULD return the value stored in the "error" key of the file in the $_FILES array.
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 273 of file UploadedFile.php.
References Slim\Http\UploadedFile\$error.
Slim\Http\UploadedFile::getSize | ( | ) |
Retrieve the file size.
Implementations SHOULD return the value stored in the "size" key of the file in the $_FILES array if available, as PHP calculates this based on the actual size transmitted.
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 323 of file UploadedFile.php.
References Slim\Http\UploadedFile\$size.
Slim\Http\UploadedFile::getStream | ( | ) |
Retrieve a stream representing the uploaded file.
This method MUST return a StreamInterface instance, representing the uploaded file. The purpose of this method is to allow utilizing native PHP stream functionality to manipulate the file upload, such as stream_copy_to_stream() (though the result will need to be decorated in a native PHP stream wrapper to work with such functions).
If the moveTo() method has been called previously, this method MUST raise an exception.
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 177 of file UploadedFile.php.
References Slim\Http\UploadedFile\$stream, and file.
Slim\Http\UploadedFile::moveTo | ( | $targetPath | ) |
Move the uploaded file to a new location.
Use this method as an alternative to move_uploaded_file(). This method is guaranteed to work in both SAPI and non-SAPI environments. Implementations must determine which environment they are in, and use the appropriate method (move_uploaded_file(), rename(), or a stream operation) to perform the operation.
$targetPath may be an absolute path, or a relative path. If it is a relative path, resolution should be the same as used by PHP's rename() function.
The original file or stream MUST be removed on completion.
If this method is called more than once, any subsequent calls MUST raise an exception.
When used in an SAPI environment where $_FILES is populated, when writing files via moveTo(), is_uploaded_file() and move_uploaded_file() SHOULD be used to ensure permissions and upload status are verified correctly.
If you wish to move to a stream, use getStream(), as SAPI operations cannot guarantee writing to stream destinations.
string | $targetPath | Path to which to move the uploaded file. |
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. |
Implements Psr\Http\Message\UploadedFileInterface.
Definition at line 223 of file UploadedFile.php.
References file.
|
staticprivate |
Parse a non-normalized, i.e.
$_FILES superglobal, tree of uploaded file data.
array | $uploadedFiles | The non-normalized tree of uploaded file data. |
Definition at line 102 of file UploadedFile.php.
References Slim\Http\UploadedFile\$error, and $uploadedFile.
|
protected |
Definition at line 57 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct(), Slim\Http\UploadedFile\getError(), and Slim\Http\UploadedFile\parseUploadedFiles().
Slim\Http\UploadedFile::$file |
Definition at line 33 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct().
|
protected |
Definition at line 75 of file UploadedFile.php.
|
protected |
Definition at line 39 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct(), and Slim\Http\UploadedFile\getClientFilename().
|
protected |
Definition at line 63 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct().
|
protected |
Definition at line 51 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct(), and Slim\Http\UploadedFile\getSize().
|
protected |
Definition at line 69 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\getStream().
|
protected |
Definition at line 45 of file UploadedFile.php.
Referenced by Slim\Http\UploadedFile\__construct(), and Slim\Http\UploadedFile\getClientMediaType().