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 :...