当前位置:网站首页>Baidu rich text editor ueeditor single image upload cross domain
Baidu rich text editor ueeditor single image upload cross domain
2022-07-25 16:22:00 【Bitter summer Bluegrass】
Official documentation :
Revised as follows :
use Ajax Upload to solve this problem
First we need to modify ueditor.all.js, Reference here doAjax, newly added doAjaxFile Function to upload files :
function doAjaxFile(url, ajaxOptions) {
console.log('doAjaxFile-----------------------------------------------------------')
console.log(url)
console.log(ajaxOptions)
var xhr = creatAjaxRequest(),
// If the timeout
timeIsOut = false,
// Default parameters
defaultAjaxOptions = {
method: 'POST',
// Timeout time . The default is 5000, The unit is ms
timeout: 15000,
// Is it an asynchronous request . true For asynchronous requests , false Request for synchronization
async: true,
// Request data to carry .
data: {
},
processData: false,
contentType: false,
cache: false,
onsuccess:function() {
},
onerror:function() {
}
};
if (typeof url === "object") {
ajaxOptions = url;
url = ajaxOptions.url;
}
if (!xhr || !url) return;
var ajaxOpts = ajaxOptions ? utils.extend(defaultAjaxOptions,ajaxOptions) : defaultAjaxOptions;
// Timeout detection
var timerID = setTimeout(function() {
if (xhr.readyState != 4) {
timeIsOut = true;
xhr.abort();
clearTimeout(timerID);
}
}, ajaxOpts.timeout);
var method = ajaxOpts.method.toUpperCase();
var str = url + (url.indexOf("?")==-1?"?":"&")
xhr.open(method, str, ajaxOpts.async);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (!timeIsOut && xhr.status == 200) {
ajaxOpts.onsuccess(xhr);
} else {
ajaxOpts.onerror(xhr);
}
}
};
// xhr.upload.addEventListener("progress", function(event) {
// if(event.lengthComputable){
// progress.style.width = Math.ceil(event.loaded * 100 / event.total) + "%";
// }
// }, false);
xhr.send(ajaxOpts.data);
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
And then in UE.Ajax New function in :
sendfile:function(url, opts) {
doAjaxFile(url, opts);
}
Finally, replace the code of the following function :
domUtils.on(input, 'change', function())
Revised document :
Remember to replace these two files at the same time .
边栏推荐
- 哪个led显示屏厂家更好
- Waterfall flow layout
- Promise date
- mysql意向锁
- [JS advanced] JS regular correlation functions and regular objects_ 02
- Upgrade esxi6.7.0 to 7.0u3f (updated on July 12, 2022)
- What is the shortcut key for win11 Desktop Switching? Win11 fast desktop switching method
- Gap locks
- MYSQL导入sqllite表格的两种方法
- Equivalent change of resistance circuit (Ⅱ)
猜你喜欢

Sum arrays with recursion

伦敦银K线图的各种有用形态

从业务需求出发,开启IDC高效运维之路

百度富文本编辑器UEditor单张图片上传跨域
![Leetcode:6127. Number of high-quality number pairs [bit operation finding rules + the sum of two numbers is greater than or equal to K + dichotomy]](/img/b5/5c7fc70b8025cf7ef21d645a3ac22e.png)
Leetcode:6127. Number of high-quality number pairs [bit operation finding rules + the sum of two numbers is greater than or equal to K + dichotomy]

EMQX Cloud 更新:日志分析增加更多参数,监控运维更省心

今天去 OPPO 面试,被问麻了

Paper notes: highly accurate protein structure prediction with alphafold (alphafold 2 & appendix)

Food safety - do you really understand the ubiquitous frozen food?

I interviewed 8 companies and got 5 offers in a week. Share my experience
随机推荐
MySQL显式锁
Doget and dopost
Quickly deploy mqtt clusters on AWS using terraform
没错,请求DNS服务器还可以使用UDP协议
High score technical document sharing of ink Sky Wheel - Database Security (48 in total)
MySQL乐观锁
一文理解分布式开发中的服务治理
终极套娃 2.0 | 云原生交付的封装
Leetcode:154. find the minimum value II in the rotation sort array [about the middle and rear positioning dichotomy of the rotation sort array]
Exploration of 6-wire SPI transmission mode
只有1000元能买什么理财产品赚钱?
使用 Terraform 在 AWS 上快速部署 MQTT 集群
leetcode:154. 寻找旋转排序数组中的最小值 II【关于旋转排序数组的中后定位二分法】
百奥赛图与LiberoThera共同开发全人GPCR抗体药物取得里程碑式进展
Breakthrough in core technology of the large humanoid Service Robot Walker x
吴恩达逻辑回归2
[image denoising] image denoising based on bicube interpolation and sparse representation matlab source code
乐观锁悲观锁适用场景
Golang review summary
今天去 OPPO 面试,被问麻了