jQuery-File-Upload by blueimp - additional headers

前端 未结 5 1792
野的像风
野的像风 2021-02-05 11:19

I\'ve searched through wiki but couldn\'t find an answer where should I put my additional headers (for example Authorization header) in JS script? Somewhere o

5条回答
  •  春和景丽
    2021-02-05 12:11

    This is how I added the filename as a header:

    $('#upload_btn').fileupload({
        singleFileUploads: true,
        beforeSend: function(xhr, data) {
            var file = data.files[0];
            xhr.setRequestHeader('X-FileName', file.name);
        },
    });
    

提交回复
热议问题