Responsive File Manager is a PHP based file upload manager that can also be used as a TinyMCE plugin.
It is possible use tinymce to upload pdf?
Question
I´m develloping a website that needs to have an upload pdf function.
I´m already using tinymce to insert posts in the website, because its more easy to format, add images, etc.
But I also need to upload pdf, and I dont see any option for that in my tinymce4.
So I came here to ask if somebody there knows if its possible use tinymce for this purpose, or I really need to devellop the pdf uploder step by step?
Thanks!
Solution
OTHER TIPS
Yes, using a hidden form.
The 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>
The script:
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
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow