我正在开发一个网站,需要有一个上传pdf功能。
我已经使用tinymce在网站中插入帖子,因为它更容易格式化,添加图像等。
但我也需要上传pdf,我没有看到任何选项,在我的tinymce4。
所以我来这里询问是否有人知道是否有可能使用tinymce来达到这个目的,或者我真的需要一步一步地开发pdf上传程序?
谢谢!
发布于 2014-03-31 02:38:39
Responsive File Manager是一个基于PHP的文件上传管理器,也可以作为TinyMCE插件使用。
发布于 2019-05-30 05:30:03
是的,使用隐藏的形式。
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
});https://stackoverflow.com/questions/22747809
复制相似问题