//Header to create a file and send to the browser
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"filename.xml\"");
$data='<?xml version="1.0" encoding="utf-8"?>' . "\n";
$data.='<data>My Data</data>' . "\n";
echo $data;
//Header to send an existing file to the browser
$filename = '/var/www/html/rates.csv';
header('Content-type: application/csv');
header("Content-Disposition: inline; filename=".$filename);
readfile($filename);
Tags: Content-type, header