Magento 2: Controller issue

I have code in the controller eg: if($token==”) { echo ‘token not found’; exit; } else { echo $lead; exit; } But need to return this public function execute() { if(isset($getCookie)){ $lead = $this->api->getleadDataForm(‘COOKIE’, $getCookie,$allfield); $token=$this->api->getToken(); } if($token==”) { $response = ‘token not found’; } else { $response = $lead; } return $response; } But…

Image is not saving when upload it from custom frontend phtml file

Image is not saving when upload it from custom frontend phtml file Here is my Controller $path = Mage::getBaseDir(‘media’) . ‘/pres’; if (!file_exists($path)) { mkdir($path, 777, true); } if ($_FILES[‘bms_file’][‘name’] != ”) { $fname = date(‘dmYHis’).$_FILES[‘bms_file’][‘name’]; $uploader = new Varien_File_Uploader(‘bms_file’); $uploader->setAllowedExtensions(array(‘png’, ‘jpg’, ‘jpeg’, ‘docx’, ‘pdf’)); $uploader->setAllowCreateFolders(true); $uploader->setAllowRenameFiles(false); $uploader->setFilesDispersion(false); $uploader->save($path, $fname); $filen=$uploader->getUploadedFileName(); $data[‘bms_file’] = $filen; }