|
|
|
@ -32,7 +32,7 @@ class Upload extends BaseController |
|
|
|
/** |
|
|
|
* 文件上传 |
|
|
|
*/ |
|
|
|
public function upload($data,$path,$prefix = "",$fileObj = true) |
|
|
|
public function upload($data,$path,$prefix = "",$fileObj = true, $oldFile = false) |
|
|
|
{ |
|
|
|
$message=$data['message'] ?? ''; |
|
|
|
if($message){ |
|
|
|
@ -83,10 +83,16 @@ class Upload extends BaseController |
|
|
|
if(!$prefix){ |
|
|
|
$prefix=$filecate.'/'.date('Y-m-d').'/'.$uid."/"; |
|
|
|
} |
|
|
|
if ($oldFile && !$fileObj) { |
|
|
|
$rep_path = str_replace(public_path(),'',$path); |
|
|
|
$file=FileModel::where(['src'=>$rep_path,'user_id'=>$uid])->find(); |
|
|
|
$name=$file['name']; |
|
|
|
} else { |
|
|
|
$name=str_replace('.'.$info['ext'],'',$info['name']); |
|
|
|
$file=false;//FileModel::where(['md5'=>$info['md5'],'user_id'=>$uid])->find(); |
|
|
|
$file=FileModel::where(['md5'=>$info['md5'],'user_id'=>$uid])->find(); |
|
|
|
} |
|
|
|
// 判断文件是否存在,如果有则不再上传 |
|
|
|
if(!$file){ |
|
|
|
if($filecate == 'image' || !$file){ |
|
|
|
$newName = uniqid() . '.' . $info['ext']; |
|
|
|
$object = $prefix . $newName; |
|
|
|
if($this->disk=='local'){ |
|
|
|
@ -216,7 +222,7 @@ class Upload extends BaseController |
|
|
|
} elseif ($type == 'file') { |
|
|
|
$main_host = getMainHost(); |
|
|
|
$path = public_path() . '/' . ltrim(str_replace($main_host,'',$image_url),'/'); |
|
|
|
$info = $this->upload($param,$path,'', false); |
|
|
|
$info = $this->upload($param,$path,'', false, true); |
|
|
|
} else { |
|
|
|
throw new \Exception(lang('file.error')); |
|
|
|
} |
|
|
|
|