i have this code that work for me on other projects but now instead to download the file is show the file on browser
$query = "SELECT * FROM leads";
$result = $dbconn->query($query);
$filename = "leads_shaldor_" . date("Y-m-d H:i");
$filepath = "/var/www/vhosts/as7.co.il/shaldor.as7.co.il/exports/"
.$filename. ".csv";
$downpath = "http://shaldor.as7.co.il/exports/" .$filename. ".csv";
$csvFile = fopen($filepath, 'w') or die("can't open file");
fprintf($csvFile, chr(0xEF).chr(0xBB).chr(0xBF));
while($row = $result->fetch_assoc()){
fputcsv($csvFile,
array($row['id'],$row['name'],$row['phone'],$row['date']));
print_r($row);
}
fclose($csvFile);
header("Location: " . $downpath);
$result->close();
$sql->close();