Question

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")?
    }
})
Was it helpful?

Solution

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")?
        }
    })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top