86 if (is_array($env[
'slim.files']) && $env->
has(
'slim.files')) {
87 return $env[
'slim.files'];
88 } elseif (isset($_FILES)) {
89 return static::parseUploadedFiles($_FILES);
113 $parsed[$field] = [];
115 $parsed[$field] =
new static(
127 $subArray[$fileIdx][
'name'] =
$uploadedFile[
'name'][$fileIdx];
128 $subArray[$fileIdx][
'type'] =
$uploadedFile[
'type'][$fileIdx];
129 $subArray[$fileIdx][
'tmp_name'] =
$uploadedFile[
'tmp_name'][$fileIdx];
130 $subArray[$fileIdx][
'error'] =
$uploadedFile[
'error'][$fileIdx];
131 $subArray[$fileIdx][
'size'] =
$uploadedFile[
'size'][$fileIdx];
133 $parsed[$field] = static::parseUploadedFiles($subArray);
180 throw new \RuntimeException(sprintf(
'Uploaded file %s has already been moved', $this->name));
182 if ($this->stream === null) {
183 $this->stream =
new Stream(fopen($this->
file,
'r'));
229 $targetIsStream = strpos($targetPath,
'://') > 0;
230 if (!$targetIsStream && !is_writable(dirname($targetPath))) {
234 if ($targetIsStream) {
235 if (!copy($this->
file, $targetPath)) {
236 throw new RuntimeException(sprintf(
'Error moving uploaded file %s to %s', $this->name, $targetPath));
238 if (!unlink($this->
file)) {
239 throw new RuntimeException(sprintf(
'Error removing uploaded file %s', $this->name));
241 } elseif ($this->sapi) {
242 if (!is_uploaded_file($this->
file)) {
246 if (!move_uploaded_file($this->
file, $targetPath)) {
247 throw new RuntimeException(sprintf(
'Error moving uploaded file %s to %s', $this->name, $targetPath));
250 if (!rename($this->
file, $targetPath)) {
251 throw new RuntimeException(sprintf(
'Error moving uploaded file %s to %s', $this->name, $targetPath));
static parseUploadedFiles(array $uploadedFiles)
Parse a non-normalized, i.e.
getError()
Retrieve the error associated with the uploaded file.
moveTo($targetPath)
Move the uploaded file to a new location.
Represents Uploaded Files.
has($key)
Does this collection have a given key?
Slim Framework (https://slimframework.com)
Reload workbook from saved file
__construct($file, $name=null, $type=null, $size=null, $error=UPLOAD_ERR_OK, $sapi=false)
Construct a new UploadedFile instance.
Create styles array
The data for the language used.
Represents a data stream as defined in PSR-7.
getSize()
Retrieve the file size.
getClientFilename()
Retrieve the filename sent by the client.
static createFromEnvironment(Environment $env)
Create a normalized tree of UploadedFile instances from the Environment.
getClientMediaType()
Retrieve the media type sent by the client.
Value object representing a file uploaded through an HTTP request.
getStream()
Retrieve a stream representing the uploaded file.
Set page orientation and size