|
@@ -235,6 +235,7 @@ class Upload
|
|
|
'mobi' => 'application/octet-stream',
|
|
|
);
|
|
|
public $size = 0;
|
|
|
+ public static $fileHash = array();
|
|
|
public function __construct()
|
|
|
{
|
|
|
|
|
@@ -444,7 +445,7 @@ class Upload
|
|
|
$data['src'] = toUTF8($realPath);
|
|
|
$data['name'] = toUTF8($files['name']);
|
|
|
$data['file_type'] = $files['type'];
|
|
|
- $data['file_hash'] = md5_file($realPath);
|
|
|
+ $data['file_hash'] = $this->fileHash($realPath);
|
|
|
$data['size'] = $files['size'];
|
|
|
} else {
|
|
|
$data['src'] = '';
|
|
@@ -455,6 +456,18 @@ class Upload
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文件hash
|
|
|
+ *
|
|
|
+ * @param $file
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function fileHash($file) {
|
|
|
+ if(isset(self::$fileHash[$file])) return self::$fileHash[$file];
|
|
|
+ self::$fileHash[$file] = md5_file($file);
|
|
|
+ return self::$fileHash[$file];
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 上传文件
|