【发布时间】:2018-01-17 07:55:13
【问题描述】:
我正在使用 tinymce 4 上传示例中的图片,在选择要上传的图片后,我收到“HTTP 错误:404”消息。
我已经使用发布图像文件测试了示例 postAcceptor.php,它可以工作。 在发布图片的结果中,我收到了 JSON 响应:
{"location":"/home/mylogin/domains/mydomain.com/public_html/projects/projectname/img/gallery/422.jpg"}
那些额外的斜线是正确的吗? 我的初始化代码:
tinymce.init({
selector: 'textarea.content',
plugins: 'image code',
toolbar: 'undo redo | link image | code',
// enable title field in the Image dialog
image_title: true,
automatic_uploads: true,
images_upload_url: 'postAcceptor.php',
images_upload_base_path: '/img/gallery/',
images_upload_credentials: true,
file_picker_types: 'image',
// and here's our custom image picker
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 reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
var id = 'blobid' + (new Date()).getTime();
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
var base64 = reader.result.split(',')[1];
var blobInfo = blobCache.create(id, file, base64);
blobCache.add(blobInfo);
cb(blobInfo.blobUri(), { title: file.name });
};
};
input.click();
}
});
【问题讨论】:
标签: javascript tinymce tinymce-4 image-upload