0

I have this file input:

<input id="some_file_input" type="file"  name="some_file" class="custom-input-thing" data-buttonName="btn-primary" data-icon="true">

i hide the text that comes with the button, the one that says "no file selected", just becouse of the "looks":

input[type=file] {
color: transparent; 
display: block; 

}

Is there a way to change the text of the file input when the user selects the file to upload??

Thanks in advance for any help.

NachoMiguel
  • 983
  • 2
  • 15
  • 29

1 Answers1

1

Use the inputFileText plugin for this

https://github.com/datchung/jquery.inputFileText

Load this file after jQuery

<script src='jquery-input-file-text.js'></script>

Here is your jQuery code.

$("input[type=file]").on("change", function() {
    $(this).inputFileText( { text: 'Uploaded' } );
});

If a file is updated, the value of input[type=file] will be changed. We use the change event handler. Then we include the plugin function for changing the text.

Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87