The upload from my device with restriction is working
But from library is not working
The upload from my device with restriction is working
But from library is not working
@mohitchechani Apparently adding restrictions to the library uploads needs some Python codingā¦
I will inform you when Iām doneā¦
to restrict file upload on frappe path :- apps/frappe/core/doctype/file//file.json {
"fieldname": "file_type",
"fieldtype": "Select",
"label": "File Type",
"options": "JPG\nJPEG\nPNG\nPDF\nCSV\nXLS\nXLSX",
"in_list_view": 1,
"in_standard_filter": 1,
"read_only": 1
}
The provided script is functional in version 14, and I trust it will meet your requirements as well.
frappe.ui.form.on('doctype_name', {
validate: function (frm) {
// Get the file field
var fileField = frm.doc.field_name;
// Check if the file field is empty
if (fileField) {
// Define allowed file extensions
var allowedExtensions = ['.xls', '.xlsx', '.csv'];
// Get the file extension of the selected file
var fileExtension = fileField.split('.').pop().toLowerCase();
// Check if the file extension is allowed
if (!allowedExtensions.includes('.' + fileExtension)) {
frappe.msgprint(__('Only files with extensions ' + allowedExtensions.join(', ') + ' are allowed.'));
frappe.validated = false;
}
}
}
});
Check this post for a Client Script restricting the allowed file types for an Attach field (tested on develop
/ v16):