0

I cannot upload .zip files to my Wordpress network, despite making IMHO everything that is needed. I am still hit by this irritating error.

enter image description here

Details:

  1. I am a super-admin in my network.
  2. The ALLOW_UNFILTERED_UPLOADS flag is set to true
  3. Custom hook of $existing_mimes['zip'] = 'application/zip'; is added
  4. Uploading .zip files is allowed in my network:

enter image description here

Here is entire code of my hook:

function so_387865_custom_upload_mimes ( $existing_mimes ) {
    $existing_mimes['epub'] = 'application/epub+zip';
    $existing_mimes['mobi'] = 'application/x-mobipocket-ebook';
    $existing_mimes['zip'] = 'application/zip';
 
    return $existing_mimes;
}
 
add_filter('upload_mimes', 'so_387865_custom_upload_mimes');

I thought that maybe there's something wrong with the hook, so I have installed the Enhanced Media Library extension (as suggested in here). All for nothing, as it clearly shows that this MIME type is added:

enter image description here

What else should I do in order to be able to upload .zip files? I am seriously lost!

EDIT: As suggested in here, this custom hook is added directly (custom_hooks.php file in wp-content/mu-plugins/ folder). While most guides in the net says about adding custom mimes directly in the theme's code. Maybe this is a problem?

5
  • 1
    I know I've had issues in the past using a MIME type different from the one WordPress was expecting. But application/zip looks pretty standard to my eye. Have you tried giving your add_filter() call a higher priority (ie, change it to add_filter('upload_mimes', 'so_387865_custom_upload_mimes', 20 );)?
    – Pat J
    Jul 3 at 2:09
  • As for your suggestion, either I missing something or you made it exactly opposite. Codex says: "Lower numbers correspond with earlier execution". So I should rather go with 1 not 20 in order to give in higher priority. Anyway, nothing helped, neither 20 nor 1. But... As for my question. It seems it is off-topic, because this clearly is some bug in Gutenberg's File block type. I can upload these files without any problems into my Media section of the very same files. Only direct upload to File block fails.
    – trejder
    Jul 4 at 11:48
  • It's a bit confusing. I think of the number as a weight: a higher number is heavier, and therefore later. The higher the number, the later the execution; if a function at priority 1 returns foo and one at priority 100 returns bar, then WP will receive the later one and it'll be bar.
    – Pat J
    Jul 4 at 19:48
  • 1
    There is an open issue for that: core.trac.wordpress.org/ticket/40175
    – funkysoul
    Jul 5 at 5:00
  • @funkysoul Yeap, just came here to report this as well.
    – trejder
    Jul 5 at 8:56
3

The issue has nothing to do with the source code of a theme or plugin or with the configuration of Wordpress. It is:

No solution exists for the moment, except for uploading files via Media section of Wordpress Dasboard. As file upload through that way are 100% working without any problems.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.