20 UPLOAD_ERR_NO_TMP_DIR,
21 UPLOAD_ERR_CANT_WRITE,
92 if (is_string($streamOrFile)) {
93 $this->file = $streamOrFile;
94 } elseif (is_resource($streamOrFile)) {
95 $this->stream =
new Stream($streamOrFile);
97 $this->stream = $streamOrFile;
100 'Invalid stream or file provided for UploadedFile' 111 if (
false === is_int(
$error)) {
113 'Upload file error status must be an integer' 119 'Invalid error status for UploadedFile' 132 if (
false === is_int(
$size)) {
134 'Upload file size must be an integer' 147 return in_array(gettype($param), [
'string',
'NULL']);
156 return is_string($param) &&
false === empty($param);
167 'Upload file client filename must be a string or null' 182 'Upload file client media type must be a string or null' 196 return $this->error === UPLOAD_ERR_OK;
212 if (
false === $this->
isOk()) {
217 throw new RuntimeException(
'Cannot retrieve stream after it has already been moved');
253 'Invalid path provided for move operation; must be a non-empty string' 258 $this->moved = php_sapi_name() ==
'cli' 259 ? rename($this->file, $targetPath)
260 : move_uploaded_file($this->file, $targetPath);
270 if (
false === $this->moved) {
272 sprintf(
'Uploaded file could not be moved to %s', $targetPath)
setStreamOrFile($streamOrFile)
Depending on the value set file or stream variable.
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.http://php.net/is_uploaded_file http://php.net/move_uploaded_file Path to which to move the uploaded file. }
getSize()
{Retrieve the file size.Implementations SHOULD return the value stored in the "size" key of the file ...
isOk()
Return true if there is no upload error.
getClientFilename()
{Retrieve the filename sent by the client.Do not trust the value returned by this method...
setClientMediaType($clientMediaType)
__construct( $streamOrFile, $size, $errorStatus, $clientFilename=null, $clientMediaType=null)
getError()
{Retrieve the error associated with the uploaded file.The return value MUST be one of PHP's UPLOAD_ER...
getStream()
{Retrieve a stream representing the uploaded file.This method MUST return a StreamInterface instance...
getClientMediaType()
{Retrieve the media type sent by the client.Do not trust the value returned by this method...
Lazily reads or writes to a file that is opened only after an IO operation take place on the stream...
setClientFilename($clientFilename)
copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen=-1)
Copy the contents of a stream into another stream until the given number of bytes have been read...
Value object representing a file uploaded through an HTTP request.