通过传递session_id即可解决,在后台接收PHPSESSID参数,判断当前session是否为空,
如果为空,通过PHPSESSID恢复之前的session。
var session_id = \\\'\\\';
KindEditor.ready(function(K) {
var editor = K.editor({
allowFileManager : false,
uploadJson : \\\'/index.php?r=public/multiupload\\\',
extraFileUploadParams: {},
});
//批量上传图片
K(\\\'#J_selectImage\\\').click(function() {
dir = \\\'sub_images\\\';
editor.extraFileUploadParams.PHPSESSID = session_id;
editor.extraFileUploadParams.dir = dir;
editor.loadPlugin(\\\'multiimage\\\', function() {
editor.plugin.multiImageDialog({
clickFn : function(urlList) {
console.log(urlList);
editor.hideDialog();
}
});
});
});
}
后台代码:
$PHPSESSID = $_POST[\\\'PHPSESSID\\\'];
if(!empty($PHPSESSID)) {
session_id($PHPSESSID);
}
后台代码要放在session_start前。
以上代码不行的话说明版本也许不符,还以有以下方法
KindEditor.ready(function(K) {
var editor = K.editor({
//uploadJson : \'index/upload_car.php?session_id=oqs3ufmi6cbi31fojs0h3mc414\', //单独引用up文件传送sessonid
extraFileUploadParams: {
PHPSESSID : \'<?php echo session_id() ?>\'
}, //这行也可以解决
后台程序不变同上处理