Php: how to convert uploaded word files to html _ PHP Tutorial

Source: Internet
Author: User
Php converts the uploaded word file to html. Php: how to convert an uploaded word file to html this article describes how to convert an uploaded word file to html in php. 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:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

File Upload

Receiving page:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

Receive uploaded files

$ 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 name

Echo $ uploadfile;

Echo"
";

$ Temploadfile = $ _ FILES ['filename'] ['tmp _ name'];

Echo $ temploadfile;

Echo"
";

Move_uploaded_file ($ temploadfile, $ uploadfile); // move a 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 ");

?>

// 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 ("This file cannot be opened ");

$ Htmlpath = substr ($ wfilepath, 0,-4 );

$ Word-> ActiveDocument-> SaveAs ($ htmlpath, 8 );

$ Word-> quit (0 );

}

Print ("Word to html! ");

?>

I hope this article will help you with php programming.

Examples in this article describes how php can convert a 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.