javascript - How to add additional params to an XHR object (in Dropzone.JS)? - Stack Overflow

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

I am trying to upload my photos together with tags (a ma 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")?
    }
})

I am trying to upload my photos together with tags (a ma 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")?
    }
})
Share Improve this question asked Dec 20, 2013 at 9:54 MK YungMK Yung 4,6116 gold badges33 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745103537a4611420.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信