在我的 MVC 应用程序中,我允许用户使用编辑器创建一个新的 PDF 文件。我想将创建的文件保存在文件夹中,我该怎么做?这是我的视图代码:
<textarea class="ckeditor" id="message" ></textarea>
<input class="green_button" id="btnCre" type="button" text="Save" value="Save" onclick="confirmsave();"/>
function confirmsave() {
var box = dhtmlx.modalbox({
title: "PDF File Details",
text: "<div id='form_in_box'><div><label> Enter The File Name <input id='fileName' class='inform' type='text'></label><br></div><div><span class='dhtmlx_button'><input type='button' value='save' onclick='create_PDF(this)' style='width:80px;'></span><span class='dhtmlx_button'><input type='button' value='Cancel' onclick='closeFile(this)' style='width:80px;'></span></label></div></div>",
width: "300px"
});
}
function closeFile(box) {
dhtmlx.modalbox.hide(box);
}
function create_PDF(box) {
var fileName = $("#fileName").val();
var content = CKEDITOR.instances["message"].getData();
if (content == "") {
alert("Enter Content in The Editor");
return false;
}
dhtmlx.modalbox.hide(box);
dhtmlx.message("Saving file...");
$.post("/CreatePDF/CreatePDFile",
{
content: '' + content + ''
}, function (data) {
data = jQuery.trim(data);
alert("PDF File created succesfully");
//$("#display_thumbs").html(data);
CKEDITOR.instances["editor1"].setData("");
});
}
控制器代码是
public ActionResult CreatePDFile(FormCollection data)
{
var htmlContent = data["content"];
var fileName = data["fileName"];
return View();
}