我一直在使用Dropzone一段时间,它完美无缺。虽然,我不得不改变我的方法。我曾经把文件发送到url(像往常一样在Dropzone中),但是,我需要将它发送到多个url(同一个文件)。我找不到答案。有人知道原因吗?
答案 0 :(得分:0)
我不认为dropzone中有内置功能可以执行此操作,但您可以为每个额外的网址发送额外的xmlhttprequest
,您可以在任何获得dropzone文件对象。
这是在默认上传成功时发送它的最低限度示例:
JS:
Dropzone.options.myDropzone = {
// This is the default dropzone url in case is not defined in the html
url: 'upload.php',
init: function() {
this.on('success', function(file){
// Just to see default serve response on console
console.log(file.xhr.responseText);
// Creat a new xmlhttprequest with the second url
secondRequest = new XMLHttpRequest();
secondRequest.open('POST', 'upload2.php', true);
// Just to see second server response on success
secondRequest.onreadystatechange = function () {
if(secondRequest.readyState === XMLHttpRequest.DONE && secondRequest.status === 200) {
console.log(secondRequest.responseText);
}
};
// Create a new formData and append the dropzone file
var secondRequestContent = new FormData();
secondRequestContent.append('file', file, file.name);
// Send the second xmlhttprequest
secondRequest.send(secondRequestContent);
});
}
};