簡體   English   中英

我想在bootstrap-fileinput中添加uploadExtraData

[英]I would like to add the uploadExtraData in bootstrap-fileinput

我正在使用bootstrap-fileinput,能夠成功上傳文件,但是我還想將一些數據(如用戶詳細信息)與文件一起發送到服務器。 有沒有添加數據的選項?

我的JavaScript代碼:

$('#xlf').fileinput({
                showPreview: false,
                uploadUrl: 'MuUrl',
                allowedFileExtensions: ['csv'],
                browseClass: "btn btn-info",
                elErrorContainer: '#errorBlock',
                msgUploadEnd: "File Uploded Successfully",
                maxFileSize: 92160
            });

使用uploadExtraData將其他數據上傳到服務器。 這僅適用於異步上傳。 如果您通過表單提交進行上傳,只需在表單的隱藏字段中添加其他數據即可發送到服務器。

Ajax提交

這是Asynch選項。

     $('#xlf').fileinput({
            showPreview: false,
            uploadUrl: 'MuUrl',
            allowedFileExtensions: ['csv'],
            browseClass: "btn btn-info",
            elErrorContainer: '#errorBlock',
            msgUploadEnd: "File Uploded Successfully",
            maxFileSize: 92160,
            // this is where the magic happens
            uploadAsync: true,
            uploadExtraData:{
               userid:'12345',
               firstname:'Jesus',
               lastname:'Christ'
            },
        });

即使答案太晚了,也希望能對某人有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM