1

I am using bootstrap file input from here:

https://github.com/kartik-v/bootstrap-fileinput

and I am trying to validate a filename after selecting a file. I tried this:

$("#mytest").fileinput({
    uploadUrl: "./upload.php",
    uploadAsync: true,      
    showPreview: false,    
    language: 'it',
    elErrorContainer: "#errorBlock"    

  })
.on('filebatchpreupload', function(event, data, id, index) {    
      return {
          message: "wrong file",
          data: {}
      };      
      }); 

and it works, but then it disable itself and I cannot do anything else.

I have noticed it does not happen if showPreview:true

I guess it's a bug? Any idea to what's happening and if it's there a workaround?

thank you!

lorife
  • 371
  • 1
  • 12
  • According to [the doc](https://plugins.krajee.com/file-input/plugin-events#filebatchselected) your `data` variable should contain the list of `File`s, and their respective name, if following the browser [`File` interface](https://developer.mozilla.org/en-US/docs/Web/API/File/File) – Jordan Quagliatini Oct 21 '20 at 16:21
  • if i use the filebatchselected and I write inside: return { message: "wrong file", data: files }; nothing happens – lorife Oct 22 '20 at 12:28

0 Answers0