我开发了一个需要上传pdf函数的网站。
我已经使用tinymce在网站上插入帖子,因为它更容易格式化,添加图片等。
但我还需要上传pdf,我在tinymce4中没有看到任何选项。
所以我来到这里询问是否有人知道它是否可能用于此目的,或者我真的需要逐步开发pdf uploder?
谢谢!
答案 0 :(得分:2)
Responsive File Manager是一个基于PHP的文件上传管理器,也可以用作TinyMCE插件。
答案 1 :(得分:0)
是,使用隐藏表单。
HTML:
<form id="PDFform"
class="hideMe"
method="post"
enctype="multipart/form-data"
<input id="pdfToken" type="hidden" name="dzToken">
<input id="fileInput" name="pdf" type="file">
</form>
脚本:
tinyMCE.init({
selector: "#tinyEditor",
themr: "modern",
plugins: [
"advlist autolink lists link charmap print preview",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table paste image paste"
],
height: 450,
force_br_newlines: false,
force_p_newlines: false,
images_upload_url: 'cgi/editorUpload.exe',
file_picker_types: 'file, image',
file_picker_callback: function(callback, value, meta) {
$("#fileInput").click(); // open the chooser
var tkn=getToken(); // set any other fields to upload with your file
$("#pdfToken").val(tkn);
$("#fileInput").on("change",function(){
var dataString=new FormData($("#PDFform")[0]);
$.ajax({
type: "POST",
url: "cgi/serverScriptToProcessFile.exe",
enctype: "multipart/form-data",
data: dataString,
processData: false,
contentType: false,
dataType: "json",
error: yourErrorHandlerFunction,
success: function(json) {
// reset the form or it won't work a 2nd time
$("#PDFuform").trigger("reset");
// if your script returns JSON you can process it here
// mine looks like {"location":"data/editorUploads/test.pdf","alt":"test.pdf"}
callback(json.location, {alt: json.alt, text: json.alt });
}
});
});
},
automatic_uploads: true
});