Skip Navigation

[Resolved] CRED file upload: adding allowed file types

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 3 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2170251

Tell us what you are trying to do?
My CRED form is only allowing .jpg and .png extensions on uploaded files. Can you tell me how to force it to accept other mime types? I can see how to further restrict it but not how to override restrictions

Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

Is there a similar example that we can see?

What is the link to your site?
transportationmanagement.us/mndot

#2170747

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

To allow or customize the mime types, you can use the native WordPress hook upload_mimes to add more mime types:
=> https://developer.wordpress.org/reference/hooks/upload_mimes/

For Example:
You can customize the following code as per your requirement.

function my_custom_mime_types( $mimes ) {
      
    // New allowed mime types.
    $mimes['svg']  = 'image/svg+xml';
    $mimes['svgz'] = 'image/svg+xml';
    $mimes['doc']  = 'application/msword'; 
  
    // Optional. Remove a mime type.
    unset( $mimes['exe'] );
  
    return $mimes;
}
  add_filter( 'upload_mimes', 'my_custom_mime_types' );

You can add such custom code at:
=> Toolset > Settings > Custom code

More info:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/