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); } $name ??= $this->getName(); $destination = $targetPath . $name; if (!$overwrite && is_file($destination)) { $destination = $targetPath . uniqid('test_', true) . '_' . $name; } if (!copy($this->getTempName(), $destination)) { return false; } @unlink($this->getTempName()); return true; } }