[英]pass HTML tags with style attributes from Javascript to PHP
我正在使用 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',
});
提前致謝。 請幫我解決這個問題
CodeIgniter 預處理(清理)輸入。 我猜$xss_clean
的參數CI_Input.post
被剝離的屬性。 嘗試
$txt=$this->input->post("cmtWRITE", FALSE);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.