gpt4 book ai didi

javascript - 如何使用 TINYMCE images_upload_handler 发送其他 POST 数据

转载 作者:行者123 更新时间:2023-11-29 23:25:27 25 4
gpt4 key购买 nike

我有一个在 TinyMCE 中工作的图像处理程序:

images_upload_handler: function (blobInfo, success, failure) {
var xhr, formData;

xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', 'queries/editorImageUpload.php');

xhr.onload = function() {
var json;

if (xhr.status != 200) {
failure('HTTP Error: ' + xhr.status);
return;
}

console.log(xhr.response);
//your validation with the responce goes here

success(xhr.response);
};

formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());

xhr.send(formData);
}

我想将另一条数据发送到“editorImageUpload”页面,作为要将图像添加到的目录的名称。但我不确定如何添加它。我会把它添加到追加行吗?:

formData.append('file','directoryNameGoesHere', blobInfo.blob(), blobInfo.filename());

或者这会弄乱追加的结构。谢谢。

最佳答案

如果您想添加更多要发送的值,只需像处理 Blob 一样附加它们

        formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
formData.append('directory','path/to/whereever');

然后读取$_POST['directory']获取值

关于javascript - 如何使用 TINYMCE images_upload_handler 发送其他 POST 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49499135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com