如何在fine uploader中在运行时添加标头
How to add headers at runtime in fine uploader
我正在使用fine uploader在服务器上上传文件,为此我需要进行2次web api调用。
点击按钮,第一个web api保存值并以整数形式返回结果,我需要在上传时将该整数结果传递到每个文件的头中。但是我不能在头中传递值,
代码,
uploader = new qq.FineUploader({
element: $('#manual-fine-uploader1')[0],
request: {
endpoint: Url.AddEvaluationFiles,
},
autoUpload: false,
text: {
uploadButton: '<i class="icon-plus icon-white"></i> 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());
}
}
});
我正在调用第一个请求的成功块中的上传功能,
$.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()
}
},
...
});
相关文章:
- 如何添加动态Id's并在运行时提取它们
- 无法在运行时将CSS样式添加到元素中
- 在运行时向 Javascript 对象添加属性
- 如何在C#MVC/Javascript中的运行时添加一个空实体
- 在运行时添加更多的ckeditor
- 在运行时添加js文件时出现语法错误
- 如何在运行时添加的对象上执行Jquery插件
- 为什么我的 init() 函数没有运行?(安装 Firefox 扩展时自动添加工具栏按钮,但仅在首次运行时)
- 在运行时将col添加到html表的colgroup中
- 使用 javascript 在运行时将 id 添加到
- 标签
- 在php中的运行时添加文本字段
- 将页面控件添加到数据表,但当代码运行时,页面中不显示任何内容
- 在运行时添加复选框并将其保存在 HTML 文件代码中
- 使用 PhoneGap 在运行时将 URL 添加到 iPhone 中 cordova.plist 文件中的白名单中
- 如何在运行时向计算可观察量添加其他数组项
- 在 IE6 中运行时添加 CSS 规则 - 对象不支持此属性或方法
- 如何在运行时将 javascript 警报添加到 innerHTML
- 如何在运行时将路由或状态添加到 Ember.Router
- 在运行时将脚本内容添加到页面
- 在填充运行时的表中添加无限滚动