6

I have some html like this:

<div class="fileinput fileinput-new" data-provides="fileinput">
    <div class="input-group">
        <div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i> <span class="fileinput-filename"></span></div>
        <span class="input-group-addon btn btn-default btn-file"><span class="fileinput-new">Select file</span><span class="fileinput-exists">Change</span><input type="file" id="File" name="..."></span>
        <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
    </div>
</div>

When the form has been submitted I want to clear the file from the input, but I don't know how to do it.

Jansy says I can do it by calling .fileinput("clear") but that doesn't work. Has anyone done this before? If so, how do I clear it?

Cheers

Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82
r3plica
  • 13,017
  • 23
  • 128
  • 290

1 Answers1

9

It was being a n00b :)

I was using

$("input[type=file]").fileinput("clear")

but I should have been using

$(".fileinput").fileinput("clear");
r3plica
  • 13,017
  • 23
  • 128
  • 290
  • That didn't worked for me due to double quotes at the fileinput parameter. Replaced that for simple quotes and worked. $(".fileinput").fileinput('clear'); Cheers! – Matias Aug 04 '15 at 16:10