将文件写入服务器磁盘而不是下载[关闭]

I generate an excel like this:

<?php
$file="test.xls";
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
?>

it works splendid. Instead of it downloading to the clients computer, can I have it write to the folder in the server?

Here's a simple way to write data to file, and using the code you provided, am offering a suggestive answer. No downvoting now folks, it's a suggestive answer and easier to post than an actual suggestion.

Note: a switch, will append to file and the will make a new line.

<?php
$file = fopen('test.xls', 'a') or die("Unable to open file for output");
$test="<table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table>
";
fwrite($file, $test) or die("Unable to write to file");
fclose($file);
echo "$test"; // echo the output
exit();
?>