文件名称:php 上传图片
文件大小:844B
文件格式:PHP
更新时间:2021-03-22 09:17:57
上传图片
$ret = array(); $upload = new \Think\Upload(); $upload->maxSize = C('ITEM_IMG_MAXSIZE');; $upload->exts = array('jpg', 'jpeg', 'png', 'gif', 'bmp'); $upload->rootPath = C('ITEM_IMG_PATH'); $upload->subName = array('date', 'Ym'); $upfinfo = $upload->upload(); if(!$upfinfo) { // 上传错误提示错误信息 $ret['error'] = true; $ret['result'] = $upload->getError(); }else{ // 上传成功 foreach($upfinfo as $k => &$file){ $file['fullpath'] = $upload->rootPath.$file['savepath'].$file['savename']; } $ret['error'] = false; $ret['result'] = $upfinfo; } return $ret;