首先上传一张图片到定义的文件夹里 然后再上传到微信公众号里,在添加一个reply_image数据表,把信息添加到这个数据表中,具体代码如下
public function upload(){
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './Upload/'; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->uploadOne($_FILES['file']);
if(!$info) {// 上传错误提示错误信息
$this->ajaxReturn(array('code'=>1,'msg'=>$upload->getError()));
}else{// 上传成功
$file= '/Upload/' . $info['savepath'] . $info['savename'];
$this->ajaxReturn(array('code'=>0,'msg'=>'上传成功','url'=>$file));
}
}
public function insertimage(){
$url=I('post.url');
$file=realpath('.'. $url);
$staus_type=I('post.staus_type');//临时,永久
$accessToken=getAccess_token();
include APP_PATH . 'LaneWeChat/lanewechat.php';
$url="https://api.weixin.qq.com/cgi-bin/