magento2.3 – About upload image

I have a extension getting upload image error

showing this meassge:

{“result”:”success”,”data”:”p1_3.jpg”}Exception: Warning: Cannot
modify header information – headers already sent by (output started at
/app/code/demo/Demo01/Controller/Post/Upload.php:91) in
/vendor/magento/framework/Stdlib/Cookie/PhpCookieManager.php on line
148 in /vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:

About Upload.php:91 is:

echo json_encode($result);

file:

    }else {
        if(isset($_FILES('file')('name')) && $_FILES('file')('name') != '') {
            $uploader = $this->_fileUploaderFactory->create(('fileId' => 'file'));
            $file = $uploader->validateFile();
            
            if(($file('name')!='') && ($file('size') >0)){
                $uploader->setAllowedExtensions(('jpg', 'jpeg', 'gif', 'png'));
                $uploader->setAllowRenameFiles(true);
                $path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('wysiwyg/'.$type);
                $uploader->save($path);
                $fileName = $uploader->getUploadedFileName();
                if($this->isFile('wysiwyg/'.$type.'/'.$fileName)){
                    $result('result') = 'success';
                    $result('data') = $fileName;
                }else{
                    $result('data') = $_FILES('file')('name');
                }
            }
        }
    }
    echo json_encode($result);

what wrong i am getting, please help.