Blog Archive

Thursday, 7 August 2014

Ajax image uploader in Drupal 7

Add the following code to 'YOUR_THEME.js' file and clear the cache

* 'file' module should be enabled.

(function ($) {
  Drupal.behaviors.autoUpload = {
    attach: function (context, settings) {
      $('form', context).delegate('input.form-file', 'change', function() {  
        $(this).next('input[type="submit"]').mousedown();
      }); 
    }
  };
})(jQuery); 

No comments:

Post a Comment