时间:2021-07-01 10:21:17 帮助过:18人阅读
{"error":0,"url":"Uploads/Allimg/2014-05-29/5386b82a78de0.jpg"}
public function uploads(){
$upload = new \Think\Upload();
$upload->maxSize = 3145728 ;
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');
$upload->rootPath = './Uploads/Allimg/';
$upload->savePath = '';
$info = $upload->upload();
if($info){
$img_url = '/Uploads/Allimg/'.$info['imgFile']['savepath'].$info['imgFile']['savename'];
echo json_encode(array('error' => 0, 'url' => $img_url));
}else{
// $upload->getError()
echo json_encode(array('error' => 1, 'message' =>'上传失败'));
}
}