mars-o mars-o -5 years ago 210
PHP Question

Why rtf code doesn't output in readable format when opened in word doc

I already have an rtf string pulled from a mysql column.
enter image description here

Then, i did some string replacement, and then output this same rtf string for download/opened by word. But it still shows the rtf code.
It should already be human readable after opening it in word right?

This is the document content after clicking view/download.
enter image description here

But, before above view, I got this error: (not sure if this is rtf related)
enter image description here

This is my code snippet for the outputting the rtf doc.

$title = $_GET["rtf"];
header("Content-Type: text/rtf");
header('Content-Disposition: '.$attachornot.'; filename="'.$title.'"');
echo $rtf_content;

Do you guys know what I did wrong here?

Answer Source

adding ob_end_clean(); before calling header() fixed this :)

thanks to my friend.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download