The scenario is as follow: when i uploaded a file with invalid extension a proper error shown, everything is fine. nothing bad with invalid extensions. where as: when i uploaded a file of larger size (greater than limit) an error shown. and if i tried second time with invalid file(i.e both for size and extensions) no error shown and file is also not uploaded. i want to display errors in all tries with invalid files. and i am using HTML5 Drag & Drop File module for uploading multiple files by browsing or drag and drop

any help please

  • 1
    Does the problem persist when you disable the drag and drop widget and just use the normal upload widget? If not, this probably needs to be a bug report to the relevant module...
    – Clive
    May 24, 2016 at 13:54
  • This sounds like a bug, so you should report an issue.
    – kenorb
    May 24, 2016 at 14:15

1 Answer 1


The error about invalid extension which you're seeing is invoked by File module in modules/file/file.js, here is a snapshot:

 * File upload utility functions.
Drupal.file = Drupal.file || {
   * Client-side file input validation of file extensions.
  validateExtension: function (event) {
    // Remove any previous errors.

    // Add client side validation for the input[type=file].
    var extensionPattern = event.data.extensions.replace(/,\s*/g, '|');
    if (extensionPattern.length > 1 && this.value.length > 0) {
      var acceptableMatch = new RegExp('\\.(' + extensionPattern + ')$', 'gi');
      if (!acceptableMatch.test(this.value)) {
        var error = Drupal.t("The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.", {

Since it worked for the first time, but not on the second time, it's possible that you've some JS error which preventing this event to be invoked. If that's not the case, make sure file.js is included on the second time.

To debug that issue, you may create a breakpoint in above code to see if it's triggered properly. If it's not, using DevTools try enabling Event Listener Breakpoints for Control change/submit events, then try to reproduce the issue, so you'll know exactly what's happening.

Test also if you can reproduce the issue with File it-self using the default theme. If not, maybe it's worth to report a bug against that module.

  • no js error i am seeing
    – Iqbal
    May 24, 2016 at 14:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.