0
기본적으로 tinymce 이미지에는 찾아보기 버튼이있어서 이미지를 선택하는 대화 상자가 표시됩니다. 내 코드에서 이미지 선택기 버튼을 tinymce에 추가하려고하지만 images_upload_handler와 결합하기가 어렵다. 마지막으로 success_callback을 사용하여 images_upload_base_path를 업데이트하는 방법을 설명합니다.파일 픽커 핸들러 및 images_upload_handler를 사용하여 tinymce로 이미지를 업로드하는 방법
tinymce.init({
...
images_upload_handler: function (blobInfo, success, failure) {
var xhr, formData;
xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', "postAcceptor.php");
xhr.onload = function() {
var json;
if (xhr.status != 200) {
failure("HTTP Error: " + xhr.status);
return;
}
json = JSON.parse(xhr.responseText);
if (!json || typeof json.location != "string") {
failure("Invalid JSON: " + xhr.responseText);
return;
}
success(json.location);
};
formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
xhr.send(formData);
}
});