[K12OSN] php - automatically opening up an rtf file in a browser

jones yeates jones_yeates at hotmail.com
Mon Feb 4 23:00:32 UTC 2008


I have this code that worked in WIndows and I tried to modify it for Linux and it isn't working.  

It basically takes an existing rtf file and replaces the text with something else and I'd like the rtf to load up within the browser.  In Windows, a popup window comes up and it has an option to open an rtf file like Word or WordPad.  For Linux some of the students are getting Firefox as the only opetion and others are getting Bluefish as the only option.  No one is getting OpenOffice.

Is there an easy way to fix this?  Do I have to change something in my httpd.conf file?

Here is the code:
        $name = $_POST['html_name'];

        if(!$name)  echo "Error";
        else
        {
                //generate headers for the browswer to choose
                //the correct application
                header('Content-Type: application/rtf');
                header('Content-Type: inline, filename=something.rtf');

                //get the file
                $filename = "example.rtf";
                $output   = file_get_contents($filename);

                //replace items
                $output = str_replace('<>', $name, $output);

                //send the generated document to the browser
                echo $output;
        }

?>

_________________________________________________________________





More information about the K12OSN mailing list