file->getUploadExtension(); return $ext && preg_match("/^[a-zA-Z0-9]+$/", $ext) ? $ext : 'file'; } public function getMime(): string { return $this->file->getUploadMimeType() ?? ''; } public function getSize(): int { $size = $this->file->getSize(); return $size !== false ? $size : 0; } public function getOriginalName(): string { return $this->file->getUploadName() ?? ''; } public function sha1(): string { $path = $this->file->getPathname(); return is_file($path) ? hash_file('sha1', $path) : ''; } public function getPathname(): string { return $this->file->getPathname(); } /** * 移动文件(兼容 ThinkPHP move($dir, $name) 与 Webman move($fullPath)) */ public function move(string $directory, ?string $name = null): self { $destination = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ($name ?? basename($this->file->getUploadName())); $this->file->move($destination); return $this; } public function getUploadFile(): UploadFile { return $this->file; } }