Allowed attachment types

Getting this error when trying to add a .txt file as attachment :

frappe.exceptions.ValidationError: You can only upload JPG, PNG, PDF, or Microsoft documents.

Any method to allow additional file types?

Seems like a behavior hardcoded into frappe in frappe/handler.py.

Hi,

May we know the version of ERPNext and in what page you are trying to add the attachment? I am able to upload a .txt file to an Item with v13.28.

The offending code in frappe/handler.py is this:

    if not file_url and (frappe.session.user == "Guest" or (user and not user.has_desk_access())):
        filetype = guess_type(filename)[0]
        if filetype not in ALLOWED_MIMETYPES:
            frappe.throw(_("You can only upload JPG, PNG, PDF, or Microsoft documents."))

Basically this is triggered when a customer that does not have desk access, trying to attach a log file when reporting Issue through the customer portal.

I’ve filed a ticket upstream.

https://github.com/frappe/frappe/issues/16882

1 Like