fix:修复分配上传名称错误
This commit is contained in:
@@ -277,6 +277,8 @@ class Upload
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->getFileSavePath($file);
|
$this->getFileSavePath($file);
|
||||||
|
// 分片上传使用ID作为文件名
|
||||||
|
$this->resource = $this->filepath . DS . sha1($params['chunkId']) . '.' . $fileExt;
|
||||||
$file->move($this->resource);
|
$file->move($this->resource);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Event::emit('uploadExceptionDelete', [
|
Event::emit('uploadExceptionDelete', [
|
||||||
@@ -352,16 +354,17 @@ class Upload
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 附件数据库保存
|
* 附件数据库保存
|
||||||
* @param $file
|
* @param $filePath
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param string|null $mimeType
|
* @param string|null $mimeType
|
||||||
* @return false|void
|
* @return false|void
|
||||||
*/
|
*/
|
||||||
public function attachment($file, string $source, string $mimeType = null)
|
public function attachment($filePath, string $source, string $mimeType = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$file = new \Webman\Http\UploadFile($file, $source, $mimeType, 200);
|
$file = new \Webman\Http\UploadFile($filePath, $source, $mimeType, 200);
|
||||||
$filePath = str_replace('\\', '/', $this->filepath . DS . $this->filename);
|
$filePath = str_replace(public_path(), '', $filePath);
|
||||||
|
$filePath = str_replace('\\', '/', $filePath);
|
||||||
$this->fileInfo = [
|
$this->fileInfo = [
|
||||||
'type' => $this->fileClass,
|
'type' => $this->fileClass,
|
||||||
'filename' => $file->getUploadName(),
|
'filename' => $file->getUploadName(),
|
||||||
@@ -372,6 +375,7 @@ class Upload
|
|||||||
'user_id' => request()->cookie('uid') ?? 0,
|
'user_id' => request()->cookie('uid') ?? 0,
|
||||||
'sha1' => md5_file($file->getPathname()),
|
'sha1' => md5_file($file->getPathname()),
|
||||||
];
|
];
|
||||||
|
|
||||||
Attachment::create($this->fileInfo);
|
Attachment::create($this->fileInfo);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->setError($e->getMessage());
|
$this->setError($e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user