I have a website running Wordpress 5.2.4 (latest at the moment). I'm trying to set it up to allow .dwg file uploads in the media library from a File Upload field in an ACF repeater. I received the error below:
"Sorry, this file type is not supported for security reasons"
.dwg files were not allowed by Wordpress, so we added it as a Mime Type in functions.php
function my_custom_mime_types( $mimes ) {
$mimes['.dwg'] = 'application/octet-stream';
return $mimes;
}
The .dwg file would still not upload from ACF File Upload, so we just tried uploading it to the Media Library directly. We discovered that we could upload the file if we clicked "Media", then clicked "Add New" in the sidebar (green arrow in the linked image below).
If however, we click "Add New" to the right of the "Media Library" heading it would still give the file type error (red arrow below in the linked image below).
I would have thought both locations used the same settings in Wordpress, but we're getting different results. The "Add New" below "Media Library" goes to media-upload.php (and works). The "Add New" to the right of "Media Library" goes to uploads.php (and does not work).
I have also added the "don't filter anything" line to wp-config.php, but no change to the issue.
define( 'ALLOW_UNFILTERED_UPLOADS', true );
Any help would be appreciated. I'm hoping that fixing the "Add New" to the right, will also fix the ACF File Upload, so taking it one step at a time.
ADDITIONAL INFO: We ran the file through a couple online mime type checkers, like checkfiletype.com. All said the file type was "application/octet-stream". I did also try the "image/vnd.dwg" mime type as suggested by @ba-webimax below, and that did not clear up the issue either.
SOLVED: @ba_webimax had it right. I did have the mime type correct, however the period was messing it up. Removing the period in front of "dwg" on the line below resolved the issue:
$mimes['dwg'] = 'application/octet-stream';
I think you are having an issue with matching the mime type. Try this...
function my_custom_mime_types( $mimes ) {
$mimes['dwg'] = 'image/vnd.dwg'; //period not necessary; use proper mime-type
return $mimes;
}
add_filter('upload_mimes', 'my_custom_mime_types');