getError() === UPLOAD_ERR_OK && is_file($this->getTempName()); } public function move(string $targetPath, ?string $name = null, bool $overwrite = false) { $targetPath = rtrim($targetPath, '/') . '/'; if (! is_dir($targetPath) && ! mkdir($targetPath, 0777, true) && ! is_dir($targetPath)) { throw HTTPException::forMoveFailed(basename($this->getTempName()), $targetPath, 'Unable to create target directory'); } if ($this->hasMoved()) { throw HTTPException::forAlreadyMoved(); } if (! $this->isValid()) { throw HTTPException::forInvalidFile(); } $name = $name ?? $this->getName(); $destination = $overwrite ? $targetPath . $name : $targetPath . $name; if (! @rename($this->getTempName(), $destination)) { if (! @copy($this->getTempName(), $destination)) { throw HTTPException::forMoveFailed(basename($this->getTempName()), $targetPath, 'rename/copy failed'); } @unlink($this->getTempName()); } $this->hasMoved = true; return true; } }