I am trying to use a socket to generate a file, the files can be very large, so the user needs to be able to continue to work while the report generates.
The problem is I am getting a bunch of html header stuff at both ends of the file. The file is an RTF and with the html stuff it won't open as an RTF.
Here is the code:
Header("Cache-control: private");
Header("Content-Type: application/rtf");
$fp = fsockopen ("thedomain.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "
POST /the_path/the_file.php HTTP/1.1
Host: www.thedoamin.com
Cache-control: private
Content-Length: 30
Content-Type: application/x-www-form-urlencoded
Content-Disposition: attachment; filename=file_rtf
Connection: Close
var1=val1&var2=val2
");
while ($fp && !feof($fp))
{
$file_rtf .= fread ($fp,128);
}
fclose ($fp);
echo $file_rtf;
}
I would think adding "-q" would do it, but I am not sure where to add it.
Thx.