Can’t upload .ppsx format files on media library

Question

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

0
sampaii 2 months 0 Answers 16 views 0

Leave an answer