PHP Tutorial Generate Word document and download code
include ("Include/conn_mysql Tutorial. php");
$id =$_get["id";
$sql = "SELECT * from down where id= $id ";
$result =mysql_query ($sql);
$row =mysql_fetch_row ($result);
$file 2= $row [ "Upload"];
Function downfile ($sFilePath)
{
if (file_exists ($sFilePath)) {
$aFilePath =explode ("/", Str_replace ("", "/", $sFilePath), $sFilePath);
$sFileName = $aFilePath [Count ($aFilePath)-1];
$nFileSize =filesize ($sFilePath);
Header ("content-disposition:attachment; Filename= ". basename ($sFileName));
Header ("Content-length:"). $nFileSize);
Header ("Content-type:application/octet-stream");
mb_convert_encoding (reaDfile ($sFilePath), "Utf-8", "GB2312");
}
Else
{
echo ("file does not exist!");
}
}
Downfile ($file 2);
/*
This generates a Word generation document program that reads data from a MySQL database tutorial and then sends the header to the browser.
*/