Import WPGet Pro
Menu

Code Snippets

Sorry, this file type is not permitted for security reasons

Fix WordPress “Sorry, this file type is not permitted for security reasons” when Import WP uploads an attachment.

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);

Allow unfiltered uploads in your wp-config.php file

To allow all the uploading of all file types you can add the following line of code to your wordpress config file wp-config.php, this will bypass the secuirty of wordpress and unrestrict what files can be uploaded, (i would recommend removing this after you have uploaded your file).

define('ALLOW_UNFILTERED_UPLOADS', true);

Updated 2023-01-25