[nycphp-talk] Problem trying to convert HTML to Word/Excel/Etc.
Phil Powell
soazine at erols.com
Sat Oct 18 20:07:11 EDT 2003
Based on the information I read in www.php.net on the header command I wrote a dummy test script to try to convert the contents of $stuff to MS Word downloadable format:
http://www.php.net/header
Code:
$stuff = '<html><head><title>stuff</title></head><body><b>Hello</b> World</body></html>';
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Content-type: application/msword; filename=stuff.doc");
//header("Content-Disposition: attachment; filename=stuff.doc");
echo $stuff;
However, upon attempting to run this script I ran into the following error in IE:
Internet Explorer could not open this script: test.php (note: I am trying to change it to be "stuff.doc"). Nothing ever showed up.
test.php (the code you see) is in a Linux environment in a folder protected by .htaccess.
In NS 7.0 it produces no errors but it tries to save the downloaded file as "test.php" and not "stuff.doc".
I am unsure how to do this in PHP although I can do it in TCL and have done it that way before, that, however, is not an option here.
Please help, I'm stuck at the very beginning of attempting customized simple reporting.
Thanx
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20031018/ecbf6cc7/attachment.html>
More information about the talk
mailing list