Can't upload format files on media library

I have an issue for uploading .ppsx format on the media library. all the powerpoint format (pptx ppt, pps) can be uploading without problem except the .ppsx format and i don't know why.

when i try to upload this format i have this message : Sorry, this file type is not permitted for security reasons.

Even though WordPress by default(wp_get_mime_types()) allow .ppsx, I try the following methods, but method 1 and 2 does not work and method 3 is not secure and does not work for no admin users.

First Method:

Add the file type through my theme functions.php (Microsoft MIME Type Confirmed Here):

function allow_file_types($mime_types){
    $mime_types['ppsx'] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';
    return $mime_types;
}
add_filter('upload_mimes', 'allow_file_types', 1, 1);

Second Method: Install plugins, which is does the exact same thing as my functions.php method.

WP Extra File Types WP Add Mime Types

Third Method: Add this line of code on the wp-config.php

define(‘ALLOW_UNFILTERED_UPLOADS’, true)

this method is not secure for me and only admin can upload the .ppsx files)

method that partially works (method 4)

The only method that partially works is to add the below code :

function my_check_filetype_and_ext( $info, $file, $filename, $mimes, $real_mime )
{
    if ( empty( $check['ext'] )  empty( $check['type'] ) )
    {
        $secondaryMimetypes = ['ppsx' = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'];

        // Run another check, but only for our secondary mime and not on core mime types.
        remove_filter( 'wp_check_filetype_and_ext', 'my_check_filetype_and_ext', 99, 5 );
        $info = wp_check_filetype_and_ext( $file, $filename, $secondaryMimetypes );
        add_filter( 'wp_check_filetype_and_ext', 'my_check_filetype_and_ext', 99, 5 );
    }

    return $info;
}
add_filter( 'wp_check_filetype_and_ext', 'my_check_filetype_and_ext', 99, 5 );

The problem is if we add this code on functions.php we will be able to upload .ppsx files but all others format can't be uploaded in media library.

Thanks in advance for your help

Topic media-settings media-library uploads media customization Wordpress

Category Web


In addition to the bug being reported, you might have some mileage trying the following in your wp-config.php file:

define( 'ALLOW_UNFILTERED_UPLOADS', true );

If you’d prefer not to edit your wp-config.php file and/or you want more control over exactly which file types can be uploaded to your site, you can use the free WP Extra File Types plugin at WordPress.org

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.