Is there a way to send Rtf file directly to browser without saving to file before ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-07-24
well I tried this with one of the examples:
just add this headers at the begining of the file, just after the includes if you want, but before any output
<?phpheader("Content-type: application/octet-stream");header("Content-Disposition: attachment; filename=file.rtf");/*populating the file...*/$rtf->save('php://output');?>
so basically you are telling the server to output directly to the browser instead of a file stream, and with the headers you are telling the browser the type and how to handle the file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to send Rtf file directly to browser without saving to file before ?
well I tried this with one of the examples:
just add this headers at the begining of the file, just after the includes if you want, but before any output
so basically you are telling the server to output directly to the browser instead of a file stream, and with the headers you are telling the browser the type and how to handle the file.
To my experience it is not completely correct.
In my case such code produced invalid rtf file.
The right one is:
Thank you for your answer.
I've already found the solution by reading the source files
just write this:
$rtf->sendRtf($filename.'.rtf'); // (filename is just de name without path…
this will send the rtf directly to the browser ready to save under the name $filename.rtf (and nothing saved on server).