I'm using tinymce 4 with image upload from example and after selecting picture to upload I'm getting "HTTP Error: 404" message.
I've tested example postAcceptor.php with posting image file and it works. On result of posting image I'm getting that JSON response:
{"location":"/home/mylogin/domains/mydomain.com/public_html/projects/projectname/img/gallery/422.jpg"}
Is that correct with those extra slashes? My code for init:
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();
}
});
The JSON you are returning sure looks like the location on the server's hard drive. The location gets turned into the src
attribute for the image so it needs to be the URL that would allow the browser to fetch the image via the web server.
404 was caused because of
images_upload_url: 'postAcceptor.php',
I've changed it to
images_upload_url: './js/tinymce/postAcceptor.php',
Worked like a charm..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.