多图上传接口-thinkphp

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)