Download MS Word document

Archived from the Xataface Users forum.

Gershy — Wed Jan 09, 2013 1:26 pm

Hey y’all, to allow the user to download ms word .doc files without COM or other libraries is very easy; this link here shows how:

http://stackoverflow.com/questions/124959/create-word-document-using-php-in-linux

(I’m using a linux server)
I’ve done this before and its worked fine, but I have an action in xataface that causes database info to download in an ms word document.

Here’s msword_output.php:

Code: Select all
`<?php
@session_start();
$lines = $_SESSION[‘msword_output’];

header(“Content-type: application/vnd.ms-word”);
header(“Content-Disposition: attachment;Filename=doc.doc”);
?>

      
</html> `

It’s very simple to use; set $_SESSION[‘msword_output’] to an array of the lines you wish to download as .doc, call include(‘msword_output.php’), and there you go.

Everything works fine except my problem is: the html is taken literally and written to the document, so instead of a line break the .doc literally says
.

This method has worked for me before, so I’m nearly positive that the issue has to do with xataface’s html context which msword_output.php is operating within.

Could anyone shed some light on this matter?

Thanks in advance!


shannah — Wed Jan 09, 2013 1:55 pm

Where is this code running? Is it a script by itself? If so it doesn’t even look like Xataface comes into play here (you’re not including any of Xataface in this example).