80,350
社区成员
发帖
与我相关
我的任务
分享
Map<String,String> map = new HashMap<String,String>();
map.put("content", matter.content);
String json;
if(matter.file!=null)
{
json = httpPost(API_URL+"Matter/Publish",map,new File(matter.file));//这段代码提交图片文件
}else
{
json = httpPost(API_URL+"Matter/Publish",map);
}
import('ORG.Net.UploadFile');
$fileType = $_POST['fileType'];
$file = $_POST['file'];
$upload = new UploadFile();
$upload->maxSize = 3292200;
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
$upload->savePath = './Uploads/';
$upload->saveRule = 'uniqid';
if (!$upload->upload()) {
//捕获上传异常
$this->error($upload->getErrorMsg());
} else {
//取得成功上传的文件信息
$uploadList = $upload->getUploadFileInfo();
$arr['file'] = $uploadList[0]['savename']; //这里是想把上传后存储的文件路径写入数据库
}