|
@@ -187,6 +187,10 @@ class Upload
|
|
|
'error' => $files['error'][$key],
|
|
|
'size' => $files['size'][$key]
|
|
|
);
|
|
|
+ // 多文件上传指定文件名的时候使用
|
|
|
+ if(isset($configure['fileNames'][$key])) {
|
|
|
+ $configure['fileName'] = $configure['fileNames'][$key];
|
|
|
+ }
|
|
|
$data['files'][] = $this->deal($file, $configure, $key);
|
|
|
}
|
|
|
return $data;
|
|
@@ -231,12 +235,14 @@ class Upload
|
|
|
|
|
|
$extension = '.' . $extension;
|
|
|
//如果是设置了保持文件名称的话,就不自动转换文件名
|
|
|
- if (isset($configure['keepFileName']) && $configure['keepFileName']) {
|
|
|
+ if(isset($configure['fileName'])) {
|
|
|
+ $fileName = $configure['fileName'];
|
|
|
+ }else if (isset($configure['keepFileName']) && $configure['keepFileName']) {
|
|
|
$fileName = pathinfo($files['name'], PATHINFO_FILENAME);
|
|
|
} else {
|
|
|
$fileName = rand(10000, 90000) . uniqid();
|
|
|
}
|
|
|
- $configure['fileName'] = $configure['prefix'] . $fileName . $extension;
|
|
|
+ $fullName = $configure['prefix'] . $fileName . $extension;
|
|
|
$subDir = $this->distribution($fileName, $configure['maxFolder']);
|
|
|
|
|
|
$fillPath = $configure['path'];
|
|
@@ -253,7 +259,7 @@ class Upload
|
|
|
}
|
|
|
}
|
|
|
//将文件名转换成URL编码,防止移动文件不成功的情况
|
|
|
- $realPath = rtrim($fillPath, '/') . '/' . $configure['fileName'];
|
|
|
+ $realPath = rtrim($fillPath, '/') . '/' . $fullName;
|
|
|
if ($files['binary']) {
|
|
|
$result = @rename($files['tmp_name'], $realPath);
|
|
|
} else {
|
|
@@ -264,6 +270,7 @@ class Upload
|
|
|
$data['src'] = toUTF8($realPath);
|
|
|
$data['name'] = toUTF8($files['name']);
|
|
|
$data['file_type'] = $files['type'];
|
|
|
+ $data['extension'] = $extension;
|
|
|
$data['file_hash'] = $this->fileHash($realPath);
|
|
|
$data['size'] = $files['size'];
|
|
|
} else {
|