Redactor / Documentation / Callbacks

Upload

uploadBeforeSend #

This callback triggers before image or file send to upload. Callback arguments are:

  • xhr - XMLHttpRequest object
$('#redactor').redactor({   
    imageUpload: '/image-upload/',   
    callbacks: {
        uploadBeforeSend: function(xhr)
        {
            console.log(xhr); 
        }
    }   
});  

You can return false in this callback to prevent uploading.

$('#redactor').redactor({   
    imageUpload: '/image-upload/',   
    callbacks: {
        uploadBeforeSend: function(xhr)
        {
			// your code		
			
			// prevent uploading
            return false;
        }
    }   
});  

uploadStart #

This callback triggers before image or file upload begins. Callback arguments are:

  • e - upload event
  • formData - form data object
$('#redactor').redactor({   
    imageUpload: '/image-upload/',   
    callbacks: {
        uploadStart: function(e, formData)
        {
            console.log('My upload started!'); 
        }
    }   
});  

You can return false in this callback to prevent uploading.

$('#redactor').redactor({   
    imageUpload: '/image-upload/',   
    callbacks: {
        uploadStart: function(e, formData)
        {
			// your code		
			
			// prevent uploading
            return false;
        }
    }   
});