自由贴: 免费、免注册、免审查匿名海报板,过期彻底删除,最高64K字节(约1.6万汉字)。图片请用 路过图床, Youimg 等图床
Page up Page up 发布新内容 Previous Page Next Page

wangEditor使用第三方图床:

首先在创建editor前自定义编辑器上传图片url:

	editor.config.customUploadImg = function(files, insert){
		var file
		for(file in files){
			var xhr = new XMLHttpRequest();
			var formData = new FormData();
			formData.append('file', files[file]);
			xhr.open("POST", '/file.php', true);
			xhr.onreadystatechange = function() {
				alert(this.responseText);
				if (this.readyState == 4 && this.status == 200) {
					var json = JSON.parse(this.responseText);
					insert(json.url);
				}
			}
			xhr.send(formData);
		} 
	}

其中/file.php为后面需要用到的反向代理的名字。

其次,修改Apache(Nginx类似)的反向代理, 在站点的conf中,增加类似代码:

SSLProxyEngine on

 ProxyPass /file.php https://www.youimg.xyz/file.php

ProxyPassReverse /file.php https://www.youimg.xyz/file.php

其中https://www.youimg.xyz 为对应的图床。

PID: 1590@2021-01-19 00:12:01 ~