Jump to content

How do I set the maxsize of a UnimFileUploadButton?


theaha

Recommended Posts

2 hours ago, theaha said:

have any solution?

Try this approach:

procedure TUnimForm1.UnimFormReady(Sender: TObject);
begin
  UnimFileUploadButton1.JSInterface.JSConfig('maxSize', [1000]); //bytes

  UnimFileUploadButton1.JSInterface.JSCode(#1+
        '.addBeforeListener("change", function(a, b) {'+
        '  isValid = true;'+
        '  for (i = 0; i < a.getFiles().length; i++) {'+
        '      if (a.getFiles()[i].size > '#1'.maxSize) {'+
        '          isValid = false;'+
        '          Ext.Msg.alert('+
        '              "MaxSize = " + '#1'.maxSize,'+
        '              a.getFiles()[i].name + ": " + '#1'.maxSizeError'+
        '          );'+
        '          return false'+
        '      }'+
        '  }'+
        '  return isValid;'+
      '});'
  );
end;

 

  • Like 1
Link to comment
Share on other sites

15 hours ago, Sherzod said:

Try this approach:

procedure TUnimForm1.UnimFormReady(Sender: TObject);
begin
  UnimFileUploadButton1.JSInterface.JSConfig('maxSize', [1000]); //bytes

  UnimFileUploadButton1.JSInterface.JSCode(#1+
        '.addBeforeListener("change", function(a, b) {'+
        '  isValid = true;'+
        '  for (i = 0; i < a.getFiles().length; i++) {'+
        '      if (a.getFiles()[i].size > '#1'.maxSize) {'+
        '          isValid = false;'+
        '          Ext.Msg.alert('+
        '              "MaxSize = " + '#1'.maxSize,'+
        '              a.getFiles()[i].name + ": " + '#1'.maxSizeError'+
        '          );'+
        '          return false'+
        '      }'+
        '  }'+
        '  return isValid;'+
      '});'
  );
end;

 

Nice Work! Thank you.

  • Thanks 1
Link to comment
Share on other sites

×
×
  • Create New...