簡體   English   中英

我想計算MS Word文件中的單詞

[英]I want to count words in ms word file

我正在使用php的COM類來計數ms word文件中的單詞數。 在我的本地計算機上運行良好。 但是,當我在服務器上運行它比它給出了錯誤。

致命錯誤:在第33行的/home/classics/public_html/filecount/index.php中找不到類'COM'

盡管我也沒有在本地上包含COM類,並且我沒有這種類型的類,但我只是這樣使用它:

<?php
    if(isset($_POST['submit'])){
        $file = $_FILES['docfile']['name'];
        $file = str_replace(" ","_",$file);
        $ranname = mt_rand(100,10000);

        //$file = file_get_contents($file);
        $ext = pathinfo($file, PATHINFO_EXTENSION);
        $target ="uploads/";
        if(!is_dir($target))
        { 
        mkdir($target, 0755);
        }

        move_uploaded_file($_FILES['docfile']['tmp_name'],$target.$ranname.".docx");
        if($ext == "doc" || $ext == "docx"){
$word = new COM("word.application") or die("Unable to instantiate Word"); 

$word->Visible = 1; 


$word->Documents->Open("/filecount/".$target.$ranname.".docx");
$temp = $word->Dialogs->Item(228); // returns wdDialogToolsWordCount dialog object
$temp->Execute();   //updates the word count
$numwords = $temp->Words(); //gets the words out of it

echo 'Word count = '.$numwords;

$word->Quit();
//unlink("uploads/".$file);
        }

    }



?>

這讓我對本地充滿信心。 但是在服務器上會給出錯誤。 請幫我怎么辦?

您確定服務器上存在該組件(“ word.application”)並將其包含在php文檔中嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM