找到kindeditor插件kindeditor-all.js,找到urltype的設置,
K.options = { designMode : true, fullscreenMode : false, filterMode : true, wellFormatMode : true, shadowMode : true, loadStyleMode : true, basePath : K.basePath, themesPath : K.basePath + 'themes/', langPath : K.basePath + 'lang/', pluginsPath : K.basePath + 'plugins/', themeType : 'default', langType : 'zh-CN', urlType : 'absolute', newlineTag : 'p',
改為absolute。然后全局搜索absolute,找到下面一行代碼:
if (mode === 'relative') { url = getRelativePath(host + pathname, 0).substr(2); } else if (mode === 'absolute') { // if (url.substr(0, host.length) === host) { // url = url.substr(host.length); // } } return url;
if (url.substr(0, host.length) === host) {
url = url.substr(host.length);
}這行代碼會把上傳的文件路徑前面的域名端口都剪掉了,所以我們嘗試將他們注釋或者刪除。就會拿到絕對路徑。
作者:weijun-w
來源:CSDN
原文:https://blog.csdn.net/qq_37705048/article/details/80936820