4

I would like to use bootstrap file input to browse a file. I am getting 3 action buttons when I use this <input id="myName" type="file" name="myName" class="file" />

and have the following line in initialization

$("#myName").fileinput({ showUpload: false, showRemove: false })

But still I see there action buttons "Remove", "Upload" and "Browse". I would like to see only "Browse". I don´t want to change css file. Is there any way to do it in html or js?

3 Answers 3

1

As per the documentation try using quotes around the options.

For example:

$("#myName").fileinput({'showUpload':false, 'showRemove':false});

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, Using quotes also did not help. I debugged the code and call is going to fileinput.js file but the returned object is not having these options. They have default options
1

As described by others yes... you need to set the showUpload and showRemove properties. You can use HTML 5 data attributes to initialize this as shown in third example on the basic usage section of the demo site - OR - you can directly use javascript to initialize as you have done.

However do not do both. The issue is you have the markup <input id="myName" type="file" name="myName" class="file" /> which has a class = file, which means the plugin will automatically intialize the plugin which is resulting in your JS init code not being processed.

Note that as highlighted in document and in the first example on basic usage the plugin automatically initializes the file input plugin if you have input type = file and class = file.

So you must just do the following if you are using javascript to initialize. First remove the class = file from your markup:

<input id="myName" type="file" name="myName"/>

Next initialize the plugin (typically on document ready) and it should work.

$(document).on('ready', function() {
    $("#myName").fileinput({ showUpload: false, showRemove: false });
});

Comments

0

One of the way which worked for me is to have those settings false in initialization.

<input id="myName" type="file" class="file" data-show-upload="false" data-show-remove="false"> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.