Do you want to allow DOC file uploads on your WordPress website?
WordPress allows you to upload audio, video, and image file formats by default. WordPress doesn’t offer DOC file uploads due to security reasons and you may encounter an error while uploading the DOC file to the WordPress media library.
Allow DOC File Uploads For All Users
If you want to enable the DOC file uploads in WordPress, use the code below.
php
/**
* Allow DOC file upload in WordPress
*/
function maverick_allow_docs_mime_types($mimes)
{
$mimes['doc'] = 'application/msword';
$mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
return $mimes;
}
add_filter('upload_mimes', 'maverick_allow_docs_mime_types');
Allow DOC File Uploads Only For Administrators
Since uploading the DOC files can put your site at risk, you can restrict DOC file upload to Site Administrators. You can use the below code to allow DOC file uploads only by administrators.
php
/**
* Allow DOC file upload in WordPress
*/
function maverick_allow_docs_mime_types($mimes)
{
//Only allow DOC File upload by admins
if (!current_user_can('administrator')) {
return $mimes;
}
$mimes['doc'] = 'application/msword';
$mimes['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
return $mimes;
}
add_filter('upload_mimes', 'maverick_allow_docs_mime_types');