微信小程序默认上传组件上传图片,PHP端处理
super
2021-06-05 18:34

ThinkPHP5.1
原代码:
if (!function_exists('upload_pic')) {
function upload_pic($path = 'base')
{
$file = request()->file('image');
$info = $file->move('./uploads/' . $path);
if ($info) {
return ['path' => '/uploads/' . $path . '/' . $info->getSaveName()];
} else {
return ['path' => '', 'msg' => $file->getError()];
}
}
}
发现接收image这个参数的时候,会报错。
将image修改成file正常(猜想小程序默认上传组件的图片字段的key叫file)

0 条讨论