12use InvalidArgumentException;
 
   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'));
 
  226            throw new RuntimeException(
'Uploaded file already moved');
 
  229        $targetIsStream = strpos($targetPath, 
'://') > 0;
 
  230        if (!$targetIsStream && !is_writable(dirname($targetPath))) {
 
  231            throw new InvalidArgumentException(
'Upload target path is not writable');
 
  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)) {
 
  243                throw new RuntimeException(
sprintf(
'%s is not a valid 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));
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Represents a data stream as defined in PSR-7.
Represents Uploaded Files.
getError()
Retrieve the error associated with the uploaded file.
static parseUploadedFiles(array $uploadedFiles)
Parse a non-normalized, i.e.
static createFromEnvironment(Environment $env)
Create a normalized tree of UploadedFile instances from the Environment.
getSize()
Retrieve the file size.
moveTo($targetPath)
Move the uploaded file to a new location.
getClientMediaType()
Retrieve the media type sent by the client.
__construct($file, $name=null, $type=null, $size=null, $error=UPLOAD_ERR_OK, $sapi=false)
Construct a new UploadedFile instance.
getStream()
Retrieve a stream representing the uploaded file.
getClientFilename()
Retrieve the filename sent by the client.
error($a_errmsg)
set error message @access public
Value object representing a file uploaded through an HTTP request.
Slim Framework (https://slimframework.com)