public function upload_img(){// 读取图片资源// 存储路径$path = "uploads/avatar";$file = request()->file('background_img');// 存储图片$info = $file->rule('uniqid')->move($path);// 存储成功if ($info) {//获取到上传图片的路径名称$name_img = $path . '/' . $info->getFilename();$msg = '上传文件成功';} else {$name_img = '';$msg = $file->getError();}//http://tm.cn/uploads/avatar/64b0c6dc0c618.png//生成图片路径return json(['code' => 1,'msg' => $msg,// 存储位置'img' => $name_img,//生成图片路径'img_url' => Config::get('setting.img_prefix') . $name_img]);}
生成链接:http://tm.cn/uploads/avatar/64b0c84c8fb0b.png