mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进File类move方法的返回对象 增加上传表单信息,增加获取文件散列值的方法
This commit is contained in:
@@ -33,6 +33,8 @@ class File extends SplFileObject
|
||||
protected $isTest;
|
||||
// 上传文件信息
|
||||
protected $info;
|
||||
// 文件hash信息
|
||||
protected $hash = [];
|
||||
|
||||
public function __construct($filename, $mode = 'r')
|
||||
{
|
||||
@@ -92,6 +94,30 @@ class File extends SplFileObject
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的md5散列值
|
||||
* @return $this
|
||||
*/
|
||||
public function md5()
|
||||
{
|
||||
if (!isset($this->hash['md5'])) {
|
||||
$this->hash['md5'] = md5_file($this->filename);
|
||||
}
|
||||
return $this->hash['md5'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的sha1散列值
|
||||
* @return $this
|
||||
*/
|
||||
public function sha1()
|
||||
{
|
||||
if (!isset($this->hash['sha1'])) {
|
||||
$this->hash['sha1'] = sha1_file($this->filename);
|
||||
}
|
||||
return $this->hash['sha1'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查目录是否可写
|
||||
* @param string $path 目录
|
||||
@@ -307,6 +333,7 @@ class File extends SplFileObject
|
||||
// 返回 File对象实例
|
||||
$file = new self($filename);
|
||||
$file->setSaveName($saveName);
|
||||
$file->setUploadInfo($this->info);
|
||||
return $file;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user