Filters the “real” file type of the given file.
Parameters
$wp_check_filetype_and_extarray- Values for the extension, mime type, and corrected filename.
extstring|falseFile extension, or false if the file doesn’t match a mime type.typestring|falseFile mime type, or false if the file doesn’t match a mime type.proper_filenamestring|falseFile name with its correct extension, or false if it cannot be determined.
$filestring- Full path to the file.
$filenamestring- The name of the file (may differ from $file due to $file being in a tmp directory).
$mimesstring[]|null- Array of mime types keyed by their file extension regex, or null if none were provided.
$real_mimestring|false- The actual mime type or false if the type cannot be determined.
Source
return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime );
You will want to use this filter as the function
finfo_filefrom PHP doesn’t always detect CSV files astext/plainortext/csv, instead it is tagged asapplication/octet-stream.This creates a problem since WordPress will not allow you to upload the file to the library or even WooCommerce import and therefore you can use the filter as follows.
The following code will help avoid using
ALLOW_UNFILTERED_UPLOADSwhen all you need to enable is one file type.