I am trying to read the file from php and downloading it from the ui on click of a button
<?php
$file = 'download.csv'; //path to the file on disk
if (file_exists($file)) {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=contact-list.csv');
header('Pragma: no-cache');
readfile($file);
//unlink($file);
exit;
}
else {
print "file not found!!!";
}
?>
But the file is not getting downloaded. No error, the code is working. unlink() function deleted the file.