I'm using wp_handle_upload to allow users upload .dcm files in the wordpress admin panel, and it does not working fine. I am also using wp_handle_upload to upload other file types ( jpg , pdf , png ) and it's working fine, but it does not work for files with dcm extension. My code is as follows

    $uploadedfile = $_FILES['dicomfile'];
    $upload_overrides = array( 'test_form' => false );
    add_filter('upload_dir', 'my_upload_dir');
    $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
    remove_filter('upload_dir', 'my_upload_dir');

    function my_upload_dir($upload) {

        $upload['subdir'] = '/test' . $upload['subdir'];

        $upload['path']   = $upload['basedir'] . $upload['subdir'];

        $upload['url']    = $upload['baseurl'] . $upload['subdir'];

        return $upload;


1 Answer 1


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.)

  • Thanks. I added this in function.php and it does not working and I can not upload any file types like jpg, png , ... Aug 30, 2022 at 8:04
  • That's odd. It shouldn't remove any MIME types, just add the .dcm one.
    – Pat J
    Aug 30, 2022 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.