Wordpress/Woocommerce: Sorry, this file type is not permitted for security reasons.

Wordpress/Woocommerce: Sorry, this file type is not permitted for security reasons.

Development Notes: Woocommerce | Sorry, this file type is not permitted for security reasons.

Environment: Wordpress / Woocommerce Problem: Importing product data via CSV results in an error. Importing product data fails. What we tried:
  • Checking the CSV for correct escaping.
  • Importing columns separately to isolate the cause.
How we recreated the problem: Insert html markup in one of the columns and attempt to import. Solution for this case: Add this to the bottom of the template functions file to remove the validation. Remove the code after for good general practice. // Fix for csv being detected as text/html add_filter( 'wp_check_filetype_and_ext', function( $result, $file, $filename, $mimes, $real_mime ) { if ( $result['ext'] == false ) { $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype['ext']; if ( $ext == 'csv' && $real_mime == 'text/html' ) { $result['ext'] = $ext; $result['type'] = 'text/csv'; } } return $result; }, 10, 5 ); Conclusion Commonly relates to the short description and the long description product data columns, due to html markup.
WordPress Figma Framer Magento Wix Contentful