我使用CKeditor和一个文件输入元素。我正在使用FormData在Jquery Ajax中传递它。这是我的Jquery函数。
function sample(){
var cmtWRITE=CKEDITOR.instances['cmtWRITE'].getData();
var vpb_files = document.getElementById('vpb-data-file').files;
var vpb_data = new FormData();
$.each(storedFiles, function(keys, values)
{
vpb_data.append(keys, values);
});
vpb_data.append('cmtWRITE', cmtWRITE);
console.log(cmtWRITE); // here just for confirmation
for (var pair of vpb_data.entries()) {
console.log("### "+pair[0]+ ', ' + pair[1]); // here just for confirmation
}
$.ajax({
url: base_url+'aaa/xxxx',
type: 'POST',
data: vpb_data,
cache: false,
processData: false,
contentType: false,
dataType : 'html',
beforeSend: function()
{
//doing some process
},
success: function(response)
{
//doing response
},
error:
function(e){
console.log('Error while request..'+JSON.stringify(e));
}
});
}
在php函数中获取值
$txt=$this->input->post("cmtWRITE");
当我回显$ txt或直接$ this-> input-> post(" cmtWRITE")时,它打印为:
<p>Okay<em> </em><span [removed]>Noted</span></p>
但在控制台实际值是
<p>Okay<em> </em><span style='color:#ff0000'>Noted</span></p>
这里我通过CK编辑器添加了字体颜色。但是在PHP端获取[删除],这使得没有添加样式的字体。 这里是我的ckeditor Init
CKEDITOR.replace( "cmtWRITE", {
// Define the toolbar groups as it is a more accessible solution.
toolbarGroups: [
{"name":"basicstyles","groups":["basicstyles"]},
{"name":"links","groups":["links"]},
{"name":"paragraph","groups":["list","blocks"]},
{"name":"insert","groups":["smiley"]},
{"name":"styles","groups":["TextColor"]},
{"name":"colors","groups":["TextColor"]}
],
// Remove the redundant buttons from toolbar groups defined above.
removeButtons: 'Strike,Subscript,Superscript,Anchor,Specialchar,Image,Source,About,Flash,Table,SpecialChar,Iframe,HorizontalRule,PageBreak',
height:'100px'
//removePlugins: 'clipboard',
});
提前致谢。请帮我解决这个问题
答案 0 :(得分:1)
CodeIgniter预处理(清理)输入。我猜测CI_Input.post
的$xss_clean
参数是剥离属性。试试
$txt=$this->input->post("cmtWRITE", FALSE);