Form Uploader Custom Error Message

Hi,

I’m working with the dhtmlxForm specifically with the uploader in html5 mode, I want to display a custom error message when the upload fails, I’m using the event onUploadFail but it only receives the realName as a parameter

form.attachEvent(‘onUploadFail’,function(realName){
$(‘textarea[name=“errors”]’).append(‘File’ + realName + ’ could not be uploaded\r\n’);
}).

My server side script does some internal validation and already returns the proper error message like this:
{state:‘cancelled’,error: File ID 1826 already exists, cant upload it again!}

But I can’t seem to find a way to catch that error message, is there an easy way to achieve this?

I’m using dhtmlxSuite_v35_pro_120822

Thanks in advanced.

Hi

  1. please use attached updates

  2. change response a bit:

{state: false, extra: { error: "File ID 1826 already exists, cant upload it again!" } }
  1. on client side:

form.attachEvent('onUploadFail', function(realName, extra){ $('textarea[name="errors"]').append( 'File' + realName + ' could not be uploaded' + (extra != null && extra.error != null? ' (' + extra.error + ')' : '') + '\r\n' ); });
dhtmlxform_item_upload.zip (7.87 KB)

Hi, I’m using dhtmlx.js to include all of the components from this location

Do I add it to the ext folder and then add the script via html for it to work?

Example

yes, should be good

first

then

Thanks for the quick support, it works like a charm! :smiley: