How to add allow ZIP files as uploads in WordPress

Years ago I added an additional MIME type to one of my websites so that I could allow a strange proprietary file type to upload directly. Back in those days, only a handful were allowed, and it included the ZIP format. I never had issues uploading those.

As the world gradually becomes a shitter place, security is tightened and I guess sometime recently ZIP files were no longer allowed in WordPress by default. Thankfully I remember how I did it, and I thought I’ll share it with you.

Add the following snippet to your functions.php file. I have it as part of my theme:

function allow_zip_uploads ( $existing_mimes=array() ) { 
  
   $existing_mimes['zip'] = 'application/zip';
   $existing_mimes['gz'] = 'application/x-gzip';
   return $existing_mimes;
}
add_filter('upload_mimes', 'allow_brush_file_uploads');

This will add both ZIP and GZIP type archives to your upload allowances.

Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

You can leave a comment on my original post.