今天做小程序图片上传,后台接收数据的时候,前端遇到了一个问题,如下:
uploadFile:fail Error: unable to verify the first certificate
uploadFile:fail ssl hand shake error
说是证书错误,我于是就百度,找到个查域名证书状态的网站
然后检查了域名。发现第二个证书缺失。如下图:
于是我就想到我在 https://freessl.cn/ 申请证书的时候是有3个,如下图:
但是我再宝塔里面只填了2个,如下图:
网上查到要把CA证书 添加到 配置文件 SSLCertificateChainFile 值里面,如下图:
然后就可以了,但是微信开发工具测试不行,必须要真机测试才能上传成功。
微信小程序 wx.uploadFile 的 name参数值为 images
php的代码//图片上传
function uplodeimg(){
$request = Request::instance();
$method = $request->method();//获取上传方式
$file = $request ->file("images");
$info = $file->move("./uploads/tmp/");
$data=$info->getInfo();
$img['pathname']=trim($info->getPathName(),".");
if(empty($img['pathname'])){
return ['code'=>"-1",'msg'=>'请重新上传'];
}else{
return ['code'=>"0",'msg'=>'success','data'=>$img];
}
exit;
}
留 言