How to upload DICOM (dcm) files using wordpress wp_handle_upload?

Unlike jpg, pdf, and png files, dcm files, by default, aren’t allowed to be uploaded by WordPress. You can add them to the allowed list using the upload_mimes filter:

add_filter( 'upload_mimes', 'wpse409071_allow_dcm_uploads' );
function wpse409071_allow_dcm_uploads( $mimes ) {
    $mimes['dcm'] = 'image/dicom';
    return $mimes;
}

(I found the MIME type here: https://www.file-extensions.org/dcm-file-extension. You might need to ensure this is the correct MIME type for a dcm file.)

error code: 523