I am trying to upload my photos together with tags (a comma delimited string) sent in an argument tagname.

The sending option passed to the Dropzone.JS allows me to get the XHR object before sending the request.

Dropzone.options.uploadDropzone({
    // ...
    sending: function(file, xhr, formData){
        // but how to add my tags string to the params?
        // any methods like setting the header: 
        // xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")?
    }
})
有帮助吗?

解决方案

in javascript

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "FileUploadHandler.ashx");
    var fd = new FormData();
    fd.append("sFileTitle", document.getElementById('txtFileTitle').value);

    xhr.send(fd);

so you would append data in form data using key and values pair

var fd = new FormData();
    fd.append("sFileTitle", document.getElementById('txtFileTitle').value);
    Dropzone.options.uploadDropzone({
        // ...
        sending: function(file, xhr, fd){
            // but how to add my tags string to the params?
            // any methods like setting the header: 
            // xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")?
        }
    })
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top