2.13.1.1.10. The file type is invalid for security reasons
WordPress only supports uploading certain file types. An error may occur when uploading an unsupported file type "Sorry, this file type is invalid for security reasons"... For the upload to be successful, either add the MIME type of the uploaded file to the list of supported ones, or disable type checking on upload.
Adding new types with plugins
Install a specialized plugin like WP Add Mime Types, and use it to add the desired MIME type to the list of allowed.
For example, to allow uploading CSV files, add the following line in the plugin settings:
CSV = text/csv
Adding new types with functions.php
Add to file functions.php
the active theme is a block of code with the following content:
function additional_mime_types($mimes) { // новые MIME-типы, которые нужно разрешить $mimes['csv'] = 'text/csv'; $mimes['doc'] = 'application/msword'; return $mimes; } add_filter('upload_mimes', 'additional_mime_types');
In the body of the function additional_mime_types
add the lines with the MIME types you need by analogy with those indicated in the example csv
and doc
.
Disabling type checking
To turn off type checking of uploaded files, add at the beginning site config file (right after <?php
) a line like this:
define('ALLOW_UNFILTERED_UPLOADS', true);