AJAX Webform + File upload. Как подружить?

При отправки вебформ через аякс не отправляется прикреплённый файл. Ниже представлен кусок кода, с помощью которого можно это дело подружить:

Вызываем хук hook_form_FORM_ID_alter() в своём модуле и прописываем в нём следующие строки:

 * Implements hook_form_FORM_ID_alter().  
function custom_module_form_webform_client_form_alter(&$form, $form_state, $form_id) {  
  $webform = $form['#node']->webform;  
  if ($webform['webform_ajax'] != WEBFORM_AJAX_NO_AJAX) {  
    foreach (array('previous', 'next', 'submit', 'draft') as $button) {  
      if (isset($form['actions'][$button])) {  
        // Add webform-ajax-submit class and javascript to fix file uploads.  
        drupal_add_js(drupal_get_path('module', 'custom_module') . '/js/webform_ajax_file.js', array('type' => 'file', 'group' => JS_THEME));  
        $form['actions'][$button]['#attributes']['class'][] = 'webform-ajax-submit';  

Далее создаём js-файл:

(function ($) {  
  // Overwrite Drupal.file.disableFields from file module to  
  // allow file fields being submitted when submitting through  
  // ajax.  
  Drupal.file.disableFields = function (event){  
    var clickedButton = this;  
    // Do not disable fields for non-ajax buttons and the  
    // webform ajax submit button.  
    if (!$(clickedButton).hasClass('ajax-processed') || $(clickedButton).hasClass('webform-ajax-submit')) {  
    // Check if we're working with an "Upload" button.  
    var $enabledFields = [];  
    if ($(this).closest('div.form-managed-file').length > 0) {  
      $enabledFields = $(this).closest('div.form-managed-file').find('input.form-file');  
    // Temporarily disable upload fields other than the one we're currently  
    // working with. Filter out fields that are already disabled so that they  
    // do not get enabled when we re-enable these fields at the end of behavior  
    // processing. Re-enable in a setTimeout set to a relatively short amount  
    // of time (1 second). All the other mousedown handlers (like Drupal's Ajax  
    // behaviors) are excuted before any timeout functions are called, so we  
    // don't have to worry about the fields being re-enabled too soon.  
    // @todo If the previous sentence is true, why not set the timeout to 0?  
    var $fieldsToTemporarilyDisable = $('div.form-managed-file input.form-file').not($enabledFields).not(':disabled');  
    $fieldsToTemporarilyDisable.attr('disabled', 'disabled');  
    setTimeout(function (){  
      $fieldsToTemporarilyDisable.attr('disabled', false);  
    }, 1000);  

Сбрасываем кеш и проверяем.