For the imce_plupload (http://drupal.org/project/imce_plupload), which integrates the plupload widget in the imce file browser, it's desirable to be able to disable file extension checking (this should be done when the file extensions is set to "*" in the imce configuration). The proper way to do this from my point of view is to just not give plupload any extensions to work with, however this means that the default extensions kick in which might give undesired effects. Is there a way to disable the checking of file types?

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

slashrsm’s picture

Version: 7.x-1.0 » 7.x-2.x-dev

It looks like currently we cannot disable extension checks. Changing this would break current default behaviour.

There is, however, 7.x-2.x branch, where we plan to rewrite the module and include changes like this.

peterpoe’s picture

I was able to remove file extension check when using IMCE by placing the following code in a custom module:
(replace MYMODULE with the name of your custom module)


/**
 * Implements hook_element_info_alter().
 */
function MYMODULE_element_info_alter(&$type) {
  if (isset($type['plupload'])) {
    $type['plupload']['#process'][] = 'MYMODULE_plupload_element_process';
  }
}

/**
 * Process plupload element.
 */
function MYMODULE_plupload_element_process($element) {
  // Remove extension validation if using IMCE.
  if (isset($element['#upload_validators']['imce_validate_all'])) {
    unset($element['#upload_validators']['file_validate_extensions']);
  }
  return $element;
}
darksnow’s picture

The hook implementation didn't work for me, but the attached patch does.

It's a simple patch to remove the default list of file extensions. This removed them from the process function and validation. In practice this will fall back to using the file extensions list from the file field in question, but as above, if that list is empty, then that should be honoured by this code, especially since plupload itself has supported this since https://github.com/moxiecode/plupload/commit/57400ddea4aa20c94944ef1c28d...

I know this may break expected defaults so understand why it may not be committed. But I think the file fields already have a default set of file extensions and unless you do something to allow that list to be empty, the defaults set in this module will never be applied.