美文网首页
多图上传接口-thinkphp

多图上传接口-thinkphp

作者: ADL2022 | 来源:发表于2018-05-29 17:48 被阅读0次

    public function uploading(){
    $id=I('uid');
    $tid=I('tid');
    $title=I('title');
    $upload = new \Think\Upload();
    //上传图片不能超过3M
    $upload->maxSize = 3145728;
    // 设置附件上传类型
    $upload->exts = array('jpg', 'png', 'jpeg');
    $upload->saveName = array('com_create_guid','');
    $upload->saveExt = 'jpg';
    $upload->rootPath = "./Upload/";
    $upload->savePath = 'images/'; // 设置附件上传(子)目录

    $info=$upload->upload();
    // $this->error($upload->getError());
    if(!$info){
    $array['code']=0;
    $array['message']=$upload->getError();
    $this->ajaxReturn ($array,'JSON');
    exit();
    }else{

    foreach ($info as $value) {
    $arr[]='/Upload'.'/'.$value['savepath'].$value['savename'];

    }
    $print['photo']=implode(';',$arr);
    // $array['photo'] = $print['photo'];

    $print['tid']=$tid;
    $print['uid']=$id;
    $print['title']=$title;
    $testaper=M('testaper')->add($print);
    }

    相关文章

      网友评论

          本文标题:多图上传接口-thinkphp

          本文链接:https://www.haomeiwen.com/subject/bxbajftx.html