public function execute()
{
$data = [];
$file = $this->getRequest()->getFiles('refundcsv');
print_r($file);//display the input file name
if (!isset($file))
{
throw new MagentoFrameworkExceptionLocalizedException(__('Invalid file upload attempt.'));
}
$data = $this->csv->getData($file); //throws error
print_r($data);
foreach ($csvData as $row => $data)
{
if ($row > 0)
{
print_r($row);
}
}
die();
}
I want to read the csv input file and validate the rows. While executing the above code shows an error.
Warning: file_exists() expects parameter 1 to be a valid path, array given in vendor/magento/framework/File/Csv.php