If you’re using the file upload field type, you can change the permitted file types by updating the ‘File types’ setting in WooCommerce > Settings > Product Add-Ons > Uploads. See this article for all settings available for upload fields.
Please remember that allowing users to upload files to your server carries a security risk, so please use this feature with caution.
If you want to upload files types that aren’t already supported by WordPress, you can filter upload_mimes:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_prefix_upload_mimes( $mimes ) { | |
// Add PhotoShop PSD files to list of permitted WordPress mime types | |
$mimes['psd'] = "application/x-photoshop"; | |
return $mimes; | |
} | |
add_filter( 'upload_mimes', 'my_prefix_upload_mimes' ); |
Here’s a list of several file types, including PSD, AI, EPS, etc:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
*/ | |
function new_prefix_pewc_get_permitted_mimes( $permitted_mimes ) { | |
$permitted_mimes['pdf'] = "application/pdf"; | |
$permitted_mimes['svg'] = 'image/svg+xml'; //Adding svg extension | |
$permitted_mimes['eps'] = 'image/x-eps'; //Adding photoshop files | |
$permitted_mimes['ai'] = 'application/postscript'; //Adding photoshop files | |
$permitted_mimes['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files | |
$permitted_mimes['xd'] = 'application/zip'; //Adding photoshop files | |
$permitted_mimes['ps'] = 'application/postscript'; //Adding photoshop files | |
$permitted_mimes['xls'] = 'application/vnd.ms-excel'; // excel file | |
$permitted_mimes['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml'; // excel file | |
$permitted_mimes['csv'] = 'text/csv'; // csv file | |
return $permitted_mimes; | |
} | |
add_filter( 'pewc_permitted_mimes', 'new_prefix_pewc_get_permitted_mimes' ); | |
function new_prefix_mime_types($mime_types){ | |
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension | |
$mime_types['eps'] = 'image/x-eps'; //Adding photoshop files | |
$mime_types['ai'] = 'application/postscript'; //Adding photoshop files | |
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files | |
$mime_types['xd'] = 'application/zip'; //Adding photoshop files | |
$mime_types['ps'] = 'application/postscript'; //Adding photoshop files | |
$mime_types['xls'] = 'application/vnd.ms-excel'; // excel file | |
$mime_types['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml'; // excel file | |
$mime_types['csv'] = 'text/csv'; // csv file | |
return $mime_types; | |
} | |
add_filter('upload_mimes', 'new_prefix_mime_types', 1, 1 ); | |
/********************************************************** | |
* Additionally, you can install the free plugin, WP Extra File Types: | |
* https://en-gb.wordpress.org/plugins/wp-extra-file-types/ | |
* And enable various file types as required | |
**********************************************************/ | |
Additionally, you can install the free plugin, WP Extra File Types, and enable various file types as required.