0

In the network setting under Upload file types I have "jpg jpeg png gif mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg wma m4a wav mp4 m4v webm ogv wmv flv"

In function.php of a subsite i've added:

function my_custom_mime_types( $mimes ) {

        // New allowed mime types.
        $mimes['csv'] = 'text/csv';
        $mimes['xls'] = 'application/vnd.ms-excel';
        // $mimes['svgz'] = 'image/svg+xml';
        // $mimes['docx'] = 'application/msword'; 

        // Optional. Remove a mime type.
        unset( $mimes['exe'] );

    return $mimes;
}
add_filter( 'mime_types', 'my_custom_mime_types' );
function my_custom_mime_typess( $mimes ) {

        // New allowed mime types.
        $mimes['csv'] = 'text/csv';
        $mimes['xls'] = 'application/vnd.ms-excel';
        // $mimes['svgz'] = 'image/svg+xml';
        // $mimes['docx'] = 'application/msword'; 

        // Optional. Remove a mime type.
        unset( $mimes['exe'] );

    return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_typess' );

The upload_mimes filter let's me upload CSV files now, but not XLS. I don't know why just CSV but not XLS. I know I can activate ALLOW_UNFILTERED_UPLOADS, but I only want to allow DOCX, XLS and XLSX. I've used mimes from here: https://codex.wordpress.org/Function_Reference/get_allowed_mime_types I even checked the mime of the file I want to upload and it's identical.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.