Can we configure the allowed file extensions for a field Attach ?
I’d like to limit to only .xml files.
this should be doable as a custom app.
hook to file - validate.
in the method check the filename.
Sure I can validate, but I want the file browser to default to *.xml instead of *.*
And I think this should be built in frappe, I’ll submit a feature request on github.
You can achieve this via the following Client Script:
frappe.ui.form.on("MY DOCTYPE", {
refresh: function (frm) {
const attach_field = frm.fields_dict["MY FIELDNAME"];
attach_field.on_attach_click = function () {
attach_field.set_upload_options();
attach_field.upload_options.restrictions.allowed_file_types = [
"application/xml",
"text/xml",
];
attach_field.file_uploader = new frappe.ui.FileUploader(attach_field.upload_options);
};
}
});
Tested on develop
/ v16.
3 Likes