Bootstrap-fileinput component passes additional parameters on upload

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.