File Max Size for an Doctype

As we set the max_file_size in System settings for overall ERP system but i want to set Overall max_file_size as 25 MB and for particular doctype i want to set 5 MB only so we can achieve this scenario?


Yes, you can define different attachment size for one doctype by clicking Customize Form and under Form Settings define the Max attachments size:


Divyesh M.

That Max Attachments option is for No of an attachment not size of an attachments.

Hii @Rehan_Ansari

In the site_config.json file, add the following:

"max_file_size": 52428800,

where the number represents the maximum file size in bytes (equivalent to 50MB).
This setting applies to the whole site.
Implementing different max_file_size values for different doctypes is not clear to me at the moment, but this solution should useful for the entire site.

Hello @Manav_Mandli,

It is just an use case like they want to set 25MB for entire System but for CRM Doctypes they restrict their user to 5MB only.

But how we can achieve that i think there will be an option in Doctype to set Max Attachment Size for Doctype level.


Please try the following Client script to limit the attachment size on particular doctype:

frappe.ui.form.on('Lead', {
    validate: function(frm) {
        // Get the attachments field
        var attachments = frm.doc.attachments || [];

        // Iterate through attachments
        attachments.forEach(function(attachment) {
            // Check if the attachment size is greater than 5MB (5242880 bytes)
            if (attachment.file_size > 5242880) {
                // Show an error message
                frappe.msgprint(__("Attachment '{0}' is greater than 5MB and cannot be uploaded.", [attachment.file_name]));

                // Remove the attachment
                frm.doc.attachments = frm.doc.attachments.filter(function(attach) {
                    return !==;

                // Refresh the attachments section

The above example is for Lead Doctype in CRM.


Divyesh M.