代码拉取完成,页面将自动刷新
我想自定义上传文件返回的json参数,请问那里修改?
@日后再说
如果你需要自定义返回参数你需要同时更改前端和后端
php/qiniu/upload_json.php
这个文件if ($err !== null) {
$json->setCode(\JsonResult::CODE_FAIL);
$json->setMessage("上传失败.");
} else {
$json->setCode(\JsonResult::CODE_SUCCESS);
$json->setMessage("上传成功.");
// 在这里修改 setData() 方法中返回的数据就好
$json->setData(array('url' => QINIU_BUCKET_DOMAIN . $ret['key']));
}
$json->output();
plugins/multiimage/BUpload.js
的 uploadFile() 这个方法。xhr.addEventListener('load',function(e) {
if ( options.data_type == "json" ) {
var data = $.parseJSON(e.target.responseText);
// 这里拿到你需要数据,进行自定义处理
if ( data.code == "000" ) {
o.selectedList.push(data.data.url); //添加文件到上传文件列表
o.uploadSuccessNum++;
$("#img-comtainer-"+dialogSCode+ node.index).find(".file-opt-box").remove();
$("#img-comtainer-"+dialogSCode+ node.index).find(".progress").remove();
$("#img-comtainer-"+dialogSCode+ node.index).find(".success").show();
} else {
__error__(codeMessageMap[data.code], node);
}
}
}, false);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
好的,谢谢
登录 后才可以发表评论