0

I want my multisite network to be able to upload and distribute files that are not allowed by default. In multisite network settings there is a field for adding additional file formats. However this only works for very specific file formats.

According to the advice from here and here I added the following code to my theme's functions.php:

function my_new_custom_mime_types( $mimes ) {
    $mimes['pem'] = 'application/x-pem-file';
return $mimes;
}
add_filter( 'upload_mimes', 'my_new_custom_mime_types', 1 );

However I still got the same error that I am not allowed to upload such a file. The file type is not listed in the choose file dialog so I have to select All files (*.*) or use drag and drop.

Someone had the same problem and had to adjust the extensions and mime types at five to eight different spaces. Unfortunately he or she did not publish the solution.

Can anyone list all the steps necessary to allow a file type when multisite is enabled?

Edit: Although I tested with extension .pem and mimetype application/x-pem-file my list of file types is not yet complete so telling plugin x will enable pem uploads is not the answer for this question.

8
  • 1
    the filter you mentioned is missing, as are the mimetypes you tested with, and the PHP error that generated the error 500 from the error log, can you edit your question to include this information? The steps for a multisite should be the same as the steps for a single site, so the issue here is unlikely to be that you're using a multisite, but with so little technical information it's not possible to write a clear answer.
    – Tom J Nowell
    Commented Jan 5 at 16:17
  • Please edit your question to include the add_filter() code that caused your 500 error; it might be something that we can help you debug.
    – Pat J
    Commented Jan 5 at 18:15
  • Re: your edit: the mime_types filter will allow you to add more MIME types to the default list of allowed MIME types. (That's what filters do in WordPress: they allow you to change how the system works without having to update core files.)
    – Pat J
    Commented Jan 6 at 2:15
  • I figured out that if a theme is installed code should go to the theme's functions.php. This solved the Error 500 but not the initial problem. Edited the question accordingly.
    – tanGIS
    Commented Jan 6 at 12:58
  • I found this answer where it states the priority of functions.php must be increased. How would one do that?
    – tanGIS
    Commented Jan 6 at 13:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.