修复bug

This commit is contained in:
2020-05-09 17:46:28 +08:00
parent 149c0e984e
commit ad7993478a
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ function is_login() {
$module = ""; $module = "";
} }
$user = Session::get(strtolower($module) . 'Info'); $user = Session::get(strtolower($module) . 'Info');
return $user['uid']; return isset($user['uid']) ? $user['uid'] : false;
} }
/** /**
+5 -4
View File
@@ -153,18 +153,19 @@ class Upload extends Base {
protected function save($request, $upload_type){ protected function save($request, $upload_type){
$data = []; $data = [];
$file= $request->file('file'); $file= $request->file('file');
$data['savename'] = $request->param('name');
$data['name'] = $request->param('name');
$data['type'] = $upload_type; $data['type'] = $upload_type;
$data['mime'] = $request->param('type'); $data['mime'] = $request->param('type');
$data['size'] = $file->getSize(); //文件大小,单位字节 $data['size'] = $file->getSize(); //文件大小,单位字节
$data['md5'] = md5_file($file->getPathname()); $data['md5'] = md5_file($file->getPathname());
$data['sha1'] = sha1_file($file->getPathname()); $data['sha1'] = sha1_file($file->getPathname());
$data['ext'] = pathinfo($data['savename'], PATHINFO_EXTENSION); //文件扩展名 $data['savepath'] = str_replace("\\", "/", Filesystem::disk('public')->putFile($upload_type, $file, 'md5'));
$data['savepath'] = Filesystem::disk('public')->putFile($upload_type, $file, 'md5'); $data['ext'] = pathinfo($data['savepath'], PATHINFO_EXTENSION); //文件扩展名
$data['location'] = "/uploads/"; $data['location'] = "/uploads/";
$data['url'] = $data['location'] . $data['savepath']; $data['url'] = $data['location'] . $data['savepath'];
$data['real_url'] = $request->domain() . $data['url'];
$data['create_time'] = time(); $data['create_time'] = time();
$data['savename'] = $request->param('name', $data['savepath']);
$data['name'] = $request->param('name', $data['savepath']);
$attach = Attach::create($data); $attach = Attach::create($data);
$data['id'] = $attach->id; $data['id'] = $attach->id;
return $data; return $data;