Posted in: WordPress Tutorials

How to Fix “Sorry, This File Type Is Not Permitted for Security Reasons” Error in WordPress?

Sorry, this file type is not permitted for security reasons.

If you ever try to upload a file and get this message this means the file format is not among those allowed to be uploaded. WordPress allows only a handful of files to be uploaded. This is done to mitigate security risks.

When you your file is not in a format allowed, you will get the error as file type not supported.

The file format security error can also happen when the file name ends with the correct format extension. Why? Though the file format appears to be in the correct format, the file is actually saved in another format. This can happen when you save a file incorrectly.

One common problem is when you save an image file from the Web. Many websites now use Webp for images. When you save these files as .jpg and try to upload on your site, the security error will be thrown. Of course, because the image in not a jpg file even though it ends with jpg format.

WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.

Here are the file formats allowed to be uploaded in WordPress by default. You can always allow support for more file formats such as .svg illustrations.

Images: .jpg, .jpeg, .png, .gif, .ico

Audio: .mp3, .m4a, .ogg, .wav

Video: .mp4, .m4v (MPEG-4), .mov, .wmv, .avi, .mpg, .ogv, .3gp, .3g2

Documents: .pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx, .odt, .xls, .xlsx, .psd

How to Fix File Type Not Permitted Error in WordPress?

The dumbest solution this problem is to convert the file format to any one of those supported by WordPress. Alternatively, you can add support for additional file types.

To allow uploading file formats not permitted by default, you will have to add a filter to upload_mimes and add the mime type of the file you want to upload.

Here’s a code for allowing two file types: svg and psd. You can change or add as many file mimes you want in the code array for mime_types.

function wpflux_add_mime_types($mime_types){
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
return $mime_types;
}
add_filter('upload_mimes', 'wpflux_add_mime_types', 1, 1);

If you are still not able to upload the file, check with your web hosting provider. Many a times, web hosts restrict support for some file types. Check if that’s the cause of your problem.

That’s all to enable support for file types not allowed uploading for security reasons by default in WordPress.