$name ??=
$this->
getName();
$destination =
$overwrite ?
$targetPath .
$name :
$this->
getDestination($targetPath .
$name);
try { $this->hasMoved =
move_uploaded_file($this->path,
$destination);
} catch (Exception
$e) { $error =
error_get_last();
$message =
strip_tags($error['message'
] ?? ''
);
throw HTTPException::
forMoveFailed(basename($this->path
),
$targetPath,
$message);
} if ($this->hasMoved === false
) { $message = 'move_uploaded_file() returned false';
throw HTTPException::
forMoveFailed(basename($this->path
),
$targetPath,
$message);
} @
chmod($targetPath, 0777 & ~
umask());
// Success, so store our new information