UEditor单个图片上传遇到的问题记录
查看了ueditor.all.js得源代码发现单图片上传是在选择文件输入框change得时候执行表单Submit,但是出现一个问题请求头没有加入Cookie,导致后端身份认证失败,上传最终失败。
ueditor.all.js 24603行原代码:
domUtils.on(iframe, 'load', callback); form.action = utils.formatUrl(imageActionUrl + (imageActionUrl.indexOf('?') == -1 ? '?':'&') + params); form.submit();
后改为了jquery提交form表单,解决了问题,
/*修改UEDITOR源码,form提交文件改为ajax上传*/ function ajaxUploadFile(url, form) { $.ajax({ cache: true, type: "POST", url: url, data: new FormData(form),// 你的formid processData: false, contentType: false, error: function (request) { }, success: function (json) { var link, json, loader, body = (iframe.contentDocument || iframe.contentWindow.document).body, result = body.innerText || body.textContent || ''; link = me.options.imageUrlPrefix + json.url; if (json.state == 'SUCCESS' && json.url) { loader = me.document.getElementById(loadingId); loader.setAttribute('src', link); loader.setAttribute('_src', link); loader.setAttribute('title', json.title || ''); loader.setAttribute('alt', json.original || ''); loader.removeAttribute('id'); domUtils.removeClasses(loader, 'loadingclass'); } else { showErrorLoader && showErrorLoader(json.state); } form.reset(); } }); } var action = utils.formatUrl(imageActionUrl + (imageActionUrl.indexOf('?') == -1 ? '?' : '&') + params); ajaxUploadFile(action, form); //domUtils.on(iframe, 'load', callback); //form.action = utils.formatUrl(imageActionUrl + (imageActionUrl.indexOf('?') == -1 ? '?':'&') + params); //form.submit();
不知何故 原form submit 请求头未携带cookie,求解
相关推荐
songshijiazuaa 2020-09-24
bbccaaa 2020-07-28
newcome 2020-04-29
Web全栈笔记 2020-05-03
vs00ASPNET 2020-04-29
jinxiutong 2020-04-23
cuiwenjie 2020-04-18
chouliqingke 2020-02-13
breakpoints 2020-01-29
poplpsure 2019-12-28
nxcjh 2020-01-03
tiankele0 2020-01-05
H女王范儿 2019-12-29
且听真言 2019-12-21
前端架构师 2019-12-19
webgm 2019-10-25