I am doing an excel plugin for my project ,i want to unlink that excel file after the completion of download by the user or cancel by the user in the popup showing for the download.
I have tried the unlink code to getting things done ,but as there is the response ,i am slightly confuse how to make it. Below i have attached some part of code . Any suggestion will highly appreciated.
$filename = time() . "-ocma-sales-report-" . date("Y-m-d") . ".xlsx"; //'.time() . '-ocma-sales-report-' . date("Y-m-d").'.xls'
$objWriter->save("temp_excel/$filename");
$filePath = 'temp_excel/' . $filename;
$this->response->file($filePath, ['download' => TRUE, 'name' => $filename]);
return $this->response;
//unlink($filename);
exit;