\thinkFile

文件上传类

Summary

Methods
Properties
Constants
__construct()
hash()
md5()
sha1()
getMime()
move()
extension()
hashName()
No public properties found
No constants found
getTargetFile()
getName()
$hash
$hashName
N/A
No private methods found
No private properties found
N/A

Properties

$hash

$hash : array

文件hash规则

Type

array

$hashName

$hashName

Methods

__construct()

__construct(string  $path, bool  $checkPath = true) : mixed

Parameters

string $path
bool $checkPath

Returns

mixed —

hash()

hash(string  $type = 'sha1') : string

获取文件的哈希散列值

Parameters

string $type

Returns

string —

md5()

md5() : string

获取文件的MD5值

Returns

string —

sha1()

sha1() : string

获取文件的SHA1值

Returns

string —

getMime()

getMime() : string

获取文件类型信息

Returns

string —

move()

move(string  $directory, string|null  $name = null) : \think\File

移动文件

Parameters

string $directory

保存路径

string|null $name

保存的文件名

Returns

\think\File —

extension()

extension() : string

文件扩展名

Returns

string —

hashName()

hashName(string|\Closure  $rule = '') : string

自动生成文件名

Parameters

string|\Closure $rule

Returns

string —

getTargetFile()

getTargetFile(string  $directory, null|string  $name = null) : \think\File

实例化一个新文件

Parameters

string $directory
null|string $name

Returns

\think\File —

getName()

getName(string  $name) : string

获取文件名

Parameters

string $name

Returns

string —