- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
WordPress. How to add additional allowed file types to be uploaded
July 27, 2015
This video tutorial is going to show how to add additional file types to be uploaded in WordPress.
WordPress. How to add additional allowed file types to be uploaded
-
Log into WordPress admin panel, then go to Media -> Add New and try to upload audio/ac3, video/x-flv or image/svg+xml file types:
-
When uploading is done, you will get a message ‘Has failed to upload due to an Error. Sorry this file type is not permitted for security reasons’:
-
To fix that, navigate to Appearance -> Editor, open custom-function.php file:
-
Add the following function into the bottom of your custom-functions.php file to allow WordPress uploading additional mime types.
add_filter('upload_mimes','add_custom_mime_types'); function add_custom_mime_types($mimes){ return array_merge($mimes,array ( 'svg' => 'image/svg+xml' )); }
-
Notice that the file extension goes as the key in $mime_types associated array and the mime type goes as its value.
In this example, svg file extension represents files with the mime type image/svg+xml.
You can find out mime types of several common file extensions on this page.
-
Go back to Media Library and try to upload image/svg file again:
Feel free to check the detailed video tutorial below:
WordPress. How to add additional allowed file types to be uploaded