Allow any file upload WordPress

26 Apr

So today I built a profile management server which is basically wordpress running on the excellent turnkey appliance, to get the .mobileconfig profile payloads uploaded I needed to edit my wp-config php file.

To do this connect via webmin or ftp, browse to your config file and add the following line below 🙂

Allow All File Types

There are two ways to override this. The easy way is adding the following line into your wp-config.php

define('ALLOW_UNFILTERED_UPLOADS', true);

Allow Specific File Types

The other way is to add custom WordPress hook in your themes functions.php file

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
 // add your extension to the array
 $existing_mimes['deb'] = 'application/x-deb';
 // add as many as you like
 // removing existing file types
 unset( $existing_mimes['exe'] );
 // add as many as you like
 // and return the new full result
 return $existing_mimes;
}

The second method is better because you can restrict only the file types you want, but if you have site where your publishers upload may types of document you can disable the restriction from wp-config.php

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: