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

Wordress Logo

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.

Share the Post:

Related Posts

AI logos (Gemini, Chat GPT)

How You Can Rank High in AI

As AI-powered tools like ChatGPT rapidly transform how people search, we’re entering a new digital gold rush—where visibility is no longer earned through traditional SEO alone. If your website isn’t structured for AI, you risk becoming invisible just as a new wave of search dominance begins. To stay competitive, your content must be clear, trustworthy, and AI-readable. In this guide, we’ll walk you through a 10-point plan to build websites that not only rank in search engines—but also get cited in AI-generated answers. Whether you’re starting fresh or optimising an existing site, now is the time to act and get ahead of the curve—before your competitors do.

Read More