I want to implement a file upload feature using LuCI.ui.FileUpload, but I'm not sure how to restrict the file upload size to no more than 100KB and only allow TXT files to be uploaded.
below is the sample code
'use strict';
'require view';
'require form';
return view.extend({
render: function() {
var m, s, o;
m = new form.Map('example', _('Example Form'), _('Example Form Configuration.'));
s = m.section(form.TypedSection, 'first', _('First Section'));
s.anonymous = true;
s.option(form.Value, 'first_option', _('First Option'), _('Input for the first option'));
s = m.section(form.TypedSection, 'second', _('Second Section'));
s.anonymous = true;
o = s.option(form.Flag, 'flag', _('Flag Option'), _('A boolean option'));
o.default = '1';
o.rmempty = false;
o = s.option(form.ListValue, 'select', _('Select Option'), _('A select option'));
o.placeholder = 'placeholder';
o.value('key1', 'value1');
o.value('key2', 'value2');
o.rmempty = false;
o.editable = true;
// Add file upload section
s = m.section(form.TypedSection, 'first', _('Upload Section'));
s.anonymous = true;
o = s.option(form.FileUpload, 'file', _('Upload File'), _('Choose a file to upload'));
return m.render();
},
});