1

Is it possible to allow zip files to be uploaded in Wordpress?

I have the following code but it doesn't work.

function custom_upload_mimes($existing_mimes = array()) {

// Add *.EPS files to Media upload
    $existing_mimes['eps'] = 'application/postscript';
// Add *.AI files to Media upload
    $existing_mimes['ai'] = 'application/postscript';
// Add *.AI files to Media upload
    $existing_mimes['3ds'] = 'application/postscript';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/acad';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-acad';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/autocad_dwg';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/dwg';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-dwg';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'application/x-autocad';
// Add *.dwg files to Media upload
    $existing_mimes['dwg'] = 'drawing/dwg';
//add .zip
    $existing_mimes['zip'] = 'application/zip';

    return $existing_mimes;
}

add_filter('upload_mimes', 'custom_upload_mimes');
  • Please explain "it doesn't seem to work". – Brady Jul 6 '12 at 10:08
7

Here is a action that works on my site:

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
    // add your extension to the mimes array as below
    $existing_mimes['zip'] = 'application/zip';
    $existing_mimes['gz'] = 'application/x-gzip';
    return $existing_mimes;
}
  • Not working for me at wp5 – Fanky Dec 11 '18 at 20:11
7

If you are using WP MultiSite you can configure the behavior the following way (tested in WP 3.8.1):

  • Go to the network settings in your browser: http://example.com/wp-admin/network/settings.php
  • Scroll down to the bottom of the settings page and you will find a list of allowed file types, add zip to it.
  • weird when adding zip file, button upload doesn't respond any more. – user310291 Jan 16 '17 at 3:57
  • Drag and drop works though – user310291 Jan 16 '17 at 4:00
1

In 5.0.3 (probably already earlier): For multisite (at least), you can edit the allowed extensions and add zip in the network settings. No need to edit files anymore.

My Sites > Network Admin > Settings > Upload file types

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.