kartik-v / bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
http://plugins.krajee.com/file-input
Other
5.36k stars 2.4k forks source link

Correctly validate persistent file validation errors and display them #1569

Closed griffgj closed 4 years ago

griffgj commented 4 years ago

Prerequisites

Steps to reproduce the issue

  1. Attempted to isolate options and below is the bare bones code that still produces the error:
var $file_upload = $("#input-705"); 
$file_upload.fileinput({
    theme: 'fas',
    uploadUrl: 'ajax.php',
    allowedFileExtensions: ['txt']
}).on('filebatchselected', function(event, files) {
        $file_upload.fileinput("upload"); 
});
  1. Set up test to look like demo here: https://plugins.krajee.com/file-input-ajax-demo/6

Expected behavior and actual behavior

When running the code above, I expect to get an error telling me the file extension of the file I have dragged into the box/selected is invalid. This does not happen but get a blank red bar instead.

If I remove "allowedFileExtensions", it works. Or if I remove "uploadUrl" it works. Or if I remove the "filebatchselected" event, it works. But if all 3 are present, it doesn't work. The file "ajax.php" does not have any affect (in one testing scenario it existed and in another it didn't and the issue persisted).

The only thing that causes the above code to work properly, that I have found, is adding "minFileCount:1" (when "maxTotalFileCount:1" exists) to the code, which seems to trigger a second error and then all of them are displayed.

Environment

Browsers

Operating System

Libraries

Isolating the problem

kartik-v commented 4 years ago

Fixed via above latest commit. Recheck and let know.

griffgj commented 4 years ago

Thank you for such a quick response! This works perfectly! Thank you for such an awesome script!