Workaround
The key configuration parameter is Uploadextradata
The specific code is as follows:
Method for obtaining additional parameters Foddertype = function () {return $ ("#fodderTypeSelect"). Val (); }; Initialize the Fileinput control (first initialization) function Initfileinput (Ctrlname, fileextensions, fileSize) {var control = $ (' # ' + Ctrlname); Control.fileinput ({language: ' zh ',//Set Language Uploadurl: "/wxmedia/imageupload",//uploaded address Allowedfileextensions:fileextensions,//receive the file suffix showupload:true,//whether the upload button is displayed SHOWC Aption:true,//whether the title is displayed, Maxfilesize:filesize * 1000,//unit is KB, if 0 means no limit to file size Browseclass: "BT N btn-primary ",//Button style Previewfileicon:" <i class= ' Glyphicon glyphicon-king ' ></i> ", Initialcaption: "Please select upload footage", uploadextradata:function (Previewid, index) {//Key points for extra parameters var obj = {}; Obj.fodder = Foddertype (); Console.log (obj); return obj; } }); }
Source connection: http://www.cnblogs.com/haijd/p/ bootstrapfileinputuploadextradata.html
Workaround
The key configuration parameter is Uploadextradata
The specific code is as follows:
Method of obtaining additional parameters Foddertype =function) {Return $ ("#fodderTypeSelect"). Val (); };Initialize the Fileinput control (first time initialization)functionInitfileinput (Ctrlname, Fileextensions, fileSize) {var control = $ (' # ' + ctrlname); Control.fileinput ({language:' En ',Set Language Uploadurl:"/wxmedia/imageupload",Upload the address allowedfileextensions:fileextensions,Received file suffix showupload:true,// whether the upload button is displayed showcaption: true,//whether the title is displayed, Maxfilesize:filesize * , //in kilobytes, If 0 means no limit on file size Browseclass: "btn btn-primary", //button style Previewfileicon: "<i class=" Glyphicon Glyphicon-king ' ></i>, initialcaption: "Please select upload footage", Uploadextradata: function (previewid, index { ///extra parameter key point var obj = {}; obj.fodder = Foddertype (); console.log (obj); return obj;} }); }
Bootstrap-fileinput component passes additional parameters on upload