0
我想添加功能到我的tinyMCE 4.X.它是文件上傳器。我試圖用很多方式去做,但沒有人工作。我使用此代碼:插入/上傳圖像到tinyMCE 4.X
tinymce.init({
selector: "textarea[name=obsah], textarea[name=perex]",
theme: "modern",
paste_data_images: true,
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor colorpicker textpattern"
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
toolbar2: "print preview media | forecolor backcolor emoticons",
image_title: true,
automatic_uploads: true,
images_upload_url: '/admin',
file_picker_types: 'image',
file_picker_callback: function(cb, value, meta) {
var input = document.createElement('input');
input.setAttribute('type', 'file');
input.setAttribute('accept', 'image/*');
input.onchange = function() {
var file = this.files[0];
var id = 'blobid' + (new Date()).getTime();
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
var blobInfo = blobCache.create(id, file);
blobCache.add(blobInfo);
cb(blobInfo.blobUri(), { title: file.name });
};
input.click();
},
});
我選擇圖像後,它顯示了在該地區,這是確定的,但是當我點擊提交,$ _ POST和$ _FILES是空的控制檯在談到錯誤JSON意外的錯誤。你能幫我嗎?如何發送多個圖像? 謝謝
Im的鏈接,可以請你幫我該如何處理呢?像 if(isset($ _ POST ['something'])){}? –
只需創建一個文件「postAcceptor.php」,並在您的tinymce選項中指定其路徑。 xhr.open('POST','postAcceptor.php') 然後在postAcceptor.php文件中更改您的域名 $ accepted_origins = array(「http:// localhost」,「http://192.168.1.1」 ,「http://example.com」); 並更改您想要上傳圖像的文件夾的路徑。 $ imageFolder =「images /」; – Sehdev