If you’re using Advanced Product Field’s file upload field, you may have noticed not all file types are allowed to be upload. This is not due to our plugin, but a WordPress security feature. Per default, WordPress only allows certain file types to be uploaded. You can find a list of allowed file types here. Configuring your site to accept other file formats, for example .psd or .ai, can be done in two ways.
1. through a plugin
You can use a free plugin like File Upload Types to configure additional file types. This is the easiest method, but requires an additional (albeit very lightweight) plugin.
2. through a code snippet
You can add a code snippet to your site that allows extra file types. You’ll need to know the MIME-type of the file format you want to allow. Find the list of MIME-types paired with file extensions here. The following example code allows SVG and photoshop files:
function msw_custom_mime_types($mime_types) { $mime_types['svg'] = 'image/svg+xml'; //Adding svg extension $mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files return $mime_types; } add_filter('upload_mimes', 'msw_custom_mime_types', 1, 1);
You can add multiple extensions by adding them to the $mime_types
array. The array key is the file extension, like psd, and the array value is the MIME-type.