open word with mysql and php
| From: | Allan Kim Jensen | Date: | Fri, 20 Dec 2002 17:56:30 +0000 |
| Subject: | open word with mysql and php | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-92783@lists.php.net to get a copy of this message | ||
Hi,
I have uploaded some files to my database and I want to retrieve the files
again. No problem. The next step is to open word if the file is a word
document and have the extension .doc and so on.
I can create a new word document but I can't open word with the file I got
in my database.
My script is like this:'
<?php
// getdata.php3 - by Florian Dittmer <dittmer@gmx.net>
// Example php script to demonstrate the direct passing of binary data
// to the user. More infos at http://www.phpbuilder.com
// Syntax: getdata.php3?id=<id>
if($id) {
// you may have to modify login information for your database server:
@MYSQL_CONNECT("myserver","think", "secret");
@mysql_select_db("binary_data");
$query = "select bin_data,filetype from binary_data where id=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
$word = new COM("word.application") or die("Unable to instanciate Word");
print "Loaded Word, version {$word->Version}\n";
//bring it to front
$word->Visible = 1;
//echo $data;
};
?>
Regards and thanks'
Allan