您無法上傳任何文件,如圖像,因爲它的源代碼。 看看文檔http://www.cdolivet.com/editarea/editarea/docs/configuration.html。在那裏,你可以個性化您的工具欄,像
toolbar: "new_document, save, load, |, charmap, |, search, go_to_line, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help"
用命令「保存」您讓您的保存按鈕。在這個按鈕你可以綁定一個功能:
editAreaLoader.init({
...
toolbar: "xx",
save_callback: "my_save_function"
});
function my_save_function (id , content) {
$.ajax({type:"POST",url:window.location.href,data:{'code':content}}).always(function(return){
alert(return);//response from your server
});
}
對於$.ajax
命令使用jQuery庫。 https://jquery.com/。 比你可以用PHP(從$ _POST ['code'])在文件(http://php.net/manual/de/function.file-put-contents.php)或數據庫中保存它。