I have the following code that makes an xls file from php:
// the top line
$topline = "This shows all the users and the user type\n";
// the headers
$titles = "Name\tSurname\tUser Type\n";
// get the users
$db = & new MySQL($connect);
$sql="SELECT * FROM `users`";
$result = $db->query($sql);
$line = array();
while ($row = $result->fetch())
{
$user_name = $row["user_name"];
$user_surname = $row["user_surname"];
$user_type = $row["user_type"];
$row ="$user_name\t$user_surname\t$user_type\n";
$line[] = $row;
}
$line = implode('',$line);
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=userreport.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header$topline$titles$line";
This creates the xls file and gives a prompt to save or open the file.
This is the line of the code that gives the prompt:
header("Content-type: application/x-msdownload");
I would like to know how to save this file to somewhere on the server rather than giving a prompt, any suggestions??