Today I was trying to import a CSV file with the WooCommerce file importer and kept getting this error: “Sorry, you are not allowed to upload this file type.” I was getting super annoyed, because the importer is specifically for a CSV file type. So what gives?
Apparently, the message appears when you try to upload a file with an extension different than what WordPress allows by default. I assumed a CSV file is pretty standard and since the woo importer was designed just for it, why on earth is the file type not allowed?
The default file types allowed are:
Images: .jpeg, .jpg, .png, .gif, .ico
Documents: .pdf, .doc, .docx, .ppt, .pptx, .pps, .ppsx, .odt, .xls, .xlsx, .psd
Audio: .mp3, .m4a, .ogg, .wav
Video: .mp4, .m4v, .mov, .wmv, .avi, .mpg, .ogv, .3gp, .3g2
Trying to upload files with extensions outside of the above will result in the “Sorry, you are not allowed to upload this file type.” error.
Don’t fret – we can fix it with a simple line of code!
You need to edit your wp-config.php file. It will be in the main directory of your site in the WordPress Install.
Above the line ‘That’s all, stop editing! Happy publishing.‘ insert the following:
define('ALLOW_UNFILTERED_UPLOADS', true);
Save the changes to the file.
Now, go back to the woo importer and refresh the page, you will now be able to import that CSV file!
For security reasons it is recommended to remove that new line you added in the wp-config.php after you upload the desired files. If you later want to upload more, you can add the line again.