Php generates Word documents and downloads the code. In the php Tutorial, generate a Word document and download the code include (includeconn_mysql tutorial. php); $ id $ _ GET [id]; $ sqlselect * fromdownwhereid $ id; $ resultmysql_query ($ SQL); $ rowmysql_fetch_r php tutorials generate Word documents 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 );
$ File2 = $ 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 ("The file does not exist! ");
}
}
DownFile ($ file2 );
/*
This word generation document program reads data from the mysql database tutorial and saves the file and sends it to the browser with the header.
*/
Pipeline generates Word documents and downloads the code include (include/conn_mysql tutorial. php); $ id = $ _ GET [id]; $ SQL = select * from down where id = $ id; $ result = mysql_query ($ SQL ); $ row = mysql_fetch_r...