Fixed: Sorry, this file type is not permitted for security reasons – WordPress

Advertisement

Have you tried uploading different file type in WordPress dashboard and notice that it is not possible? and instead you you only get this message “Sorry, this file type is not permitted for security reasons.” Actually, it is possible but you need trick, by that here I’ve provide really simple snippet for you.

Syntax


function my_mimes_type( $mime ) {
	// add the file extension to the array
	$existing_mimes['filetype'] = 'mime/type';

	//return as array
	return $existing_mimes;
}

Example

Paste this code into your fuctions.php of your current theme, most of the theme has functions.php if not go and create one.


add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes( $existing_mimes ){

	$existing_mimes['csv'] = 'application/octet-stream'; //allow CSV files

	return $existing_mimes;
}

The above example only for CSV file.

This is a common mistake; make sure you always have a file extension.

Visit this link http://codex.wordpress.org/Uploading_Files to know WordPress available files for upload.

Hope that helps

Advertisement