项目场景:
移动端签名提交之后会生成合同的pdf并且把签名图放到乙方处
问题描述
在本地和测试环境中生成的PDF都是正确的放入了签名图片,但是在生产环境中,签名图片没有放入
代码片段如下:
$signPath='/public/static/uploads/'.cookie('merchant_id').'/images/signature/'.date('Ym', $time)."/".$username['phone']."-".$time.".{$type}";
cookie('signPath', $signPath, 3*3600);
$signPath = cookie('signPath');
$html = '<h3 style="text-align: center"><b>开创空间租赁协议</b></h3>
<p>甲方: xx信息技术有限公司 </p>
<p>乙方: <img src="'.$signPath.'" width="70"> </p>
原因分析:
可能因为签名图片没有成功上传或图片地址错误导致图片插入失败
解决方案:
先排查是否权限问题导致签名图片没有上传成功,我根据路径查找之后发现图片是上传成功的,所以只能是路径不对导致图片没有获取到,于是由之间的相对路径换成了url获取,问题解决!
$signPath='http://'.$_SERVER['HTTP_HOST'].'/public/static/uploads/'.cookie('merchant_id').'/images/signature/'.date('Ym', $time)."/".$username['phone']."-".$time.".{$type}";