如何在精细上传器中在运行时添加标头

我使用精细的上传器在服务器上上传文件,为此我需要进行2次web api调用。

在按钮上单击,第一个web api保存值并返回整数结果,我需要在上传时将每个文件的标题中的整数结果传递给它。 但是我无法在标题中传递值,

码,

uploader = new qq.FineUploader({ element: $('#manual-fine-uploader1')[0], request: { endpoint: Url.AddEvaluationFiles, }, autoUpload: false, text: { uploadButton: ' Select Files' }, debug: true, callbacks: { onSubmit: function (id, fileName) { }, onStatusChange: function (id, oldStatus, newStatus) { if (newStatus == "uploading") { alert("Add header"); } }, onUpload: function (id, name) { alert("Onupload"); this.append("RequestId", $("#ReqId").val()); } } }); 

我在第一次请求的成功块中调用上传function,

 $.ajax({ type: "POST", url: Url.Details, data: fileData, async: false, success: function (result) { if (result == 0) { toastr.error("Please pass user id"); } else { $("#ReqId").val(result); alert($("#ReqId").val()); uploader.uploadStoredFiles(); } }, error: function (err) { toastr.error("Not able to upload art details"); } }); 

在这里,我想在onUpload事件中传递RequestId头,但它不起作用,我需要做些什么改变才能实现它。

request选项具有customHeaders属性,允许您设置任何自定义标头。

您的构造函数调用应该类似于

 artistmanualuploader = new qq.FineUploader({ ... request: { endpoint: "FoaUrl.AddEvaluationFiles", customHeaders: { "EvaluationRequestId": $("#CurrentEvaluationReqId").val() } }, ... });