upload_mimes not accepting CSV

Hi I am adding support for CSV uploads like so :

add_filter( 'upload_mimes',  function ( $mime_types ) {

  $mime_types['csv']  = 'text/csv';

  return $mime_types;

});

How every when I try to upload the file I still get :

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

Topic uploads Wordpress

Category Web


You can't upload anything except images, documents, audio or video files—and it's good for security, But in case you want to allow specific file type to upload in media library you will have to define ALLOW_UNFILTERED_UPLOADS.

Put this code in wp-config.php file.

define( 'ALLOW_UNFILTERED_UPLOADS', true ); 

This code doesn't allow every user to upload every file type, though. Only administrators are allowed to upload whatever they want.

Source: https://code.tutsplus.com/articles/new-wp-config-tweaks-you-probably-dont-know--wp-35396

https://codex.wordpress.org/Uploading_Files

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.