Documentation / Code Snippets

Sorry, this file type is not permitted for security reasons

If you come across the error when uploading files: “Sorry, this file type is not permitted for security reasons”, to overcome this security measure put in place by WordPress add the following code to your themes functions file.

function iwp_example_allow_xml_uploads($mime_types)
{
    $mime_types['xml'] = 'text/xml';
    $mime_types['json'] = 'application/json';
    $mime_types['csv'] = 'text/csv';

    return $mime_types;
}
add_filter('upload_mimes', 'iwp_example_allow_xml_uploads', 1);