Navigation überspringen

[Gelöst] CRED file upload: adding allowed file types

This support ticket is created vor 4 years, 8 months. 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 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 1 reply, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 4 years, 8 months.

Assistiert von: Minesh.

Author
Artikel
#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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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/