Php generates Word documents and downloads code _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.