Php implements the method of converting uploaded word files to html. _ PHP Tutorial

Source: Internet
Author: User
Php converts the uploaded word file to html ,. Php implements the method of converting the uploaded word file to html. This article describes how php implements converting the uploaded word file to html. Share it with you for your reference. The specific implementation method is as follows: php implements the method of converting the uploaded word file into html,

This example describes how to convert a word file to html in php. Share it with you for your reference. The specific implementation method is as follows:

Upload page:

 File Upload  

Receiving page:

 Receive uploaded files<? Php $ conn = @ new COM ("ADODB. connection "); $ connstr =" DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = ". realpath ("person. mdb "); $ conn-> Open ($ connstr); $ uploaddir = 'uploads/'; if (! Is_dir ($ uploaddir) {mkdir ($ uploaddir);} $ filename = $ _ FILES ['filename'] ['name']; $ filename = substr ($ _ FILES ['filename'] ["name"], 0, strpos ($ _ FILES ['filename'] ["name"], ". "); echo $ filename; echo"
"; $ Uploadfile = $ uploaddir. $ filename. substr ($ _ FILES ['filename'] ["name"], strpos ($ _ FILES ['filename'] ["name"], ". "); // directory name. file name. suffix echo $ uploadfile; echo"
"; $ Temploadfile = $ _ FILES ['filename'] ['tmp _ name']; echo $ temploadfile; echo"
"; Move_uploaded_file ($ temploadfile, $ uploadfile); // move the file $ path = $ _ SERVER ['script _ filename']; $ filepath = $ _ SERVER ["PHP_SELF"]; $ path = substr ($ path, 0, strpos ($ path, $ filepath); echo $ path; echo"
"; Echo $ filepath; $ htmlpath = $ path."/shiyan4/". $ uploadfile; echo"
"; Echo $ htmlpath; word2html ($ htmlpath); // $ query = @ mysql_query (" Insert into $ username (fname, file) values ('$ filename ', '$ uploadfile') ") or die (" error ");?> <? Php // http://tieba.baidu.com/f? Kz = 13975389 function word2html ($ wfilepath) {$ word = new COM ("Word. application ") or die (" cannot Open MS Word "); $ word-> visible = 1; $ word-> Documents-> Open ($ wfilepath) or die ("cannot open this file"); $ htmlpath = substr ($ wfilepath, 0,-4); $ word-> ActiveDocument-> SaveAs ($ htmlpath, 8 ); $ word-> quit (0);} print ("Word is converted to html! ");?>

I hope this article will help you with php programming.

Example: This article describes how php converts the uploaded word file to html. Share it with you for your reference. The specific implementation method is as follows :...

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.