txt、doc文件提交内容到textarea里面怎么做?就是有txt、doc文件,然后想在页面上做一个按钮,点这个按钮就选择txt或者doc文件,把这些文件的内容读到textarea里面,再由textarea提交到数据库,这个代码怎么写?

解决方案 »

  1.   

    通过file_get_contents()获取文本内容,显示在textarea即可。
      

  2.   

    <?    
    // 建立一个指向新COM组件的索引    
    $word = new COM(”word.application”) or die(”Can’t start Word!”);    
    // 显示目前正在使用的Word的版本号    
    //echo “Loading Word, v. {$word->Version}<br>”;    
    // 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)    
    // to open the application in the forefront, use 1 (true)    
    //$word->Visible = 0;    
    //打?一个文档    
    $word->Documents->OPen(”d:\myweb\muban.doc”);    
    //读取文档内容    
    $test= $word->ActiveDocument->content->Text;    
    echo $test;    
    echo “<br>”;    
    //将文档中需要换的sexinsex变量更换一下    
    $test=str_replace(”<{变量}>”,”这是变量”,$test);    
    echo $test;    
    $word->Documents->Add();    
    // 在新文档中添加文字    
    $word->Selection->TypeText(”$test”);  
    //把文档保存在目录中    
    $word->Documents[1]->SaveAs(”d:/myweb/comtest.doc”);    
    // 关闭与COM组件之间的连接    
    $word->Quit();    
    ?>  $file = fopen ("http://"localhost/ttt.word", "r";
        if (!$file) {
          echo "<p>;Unable to open remote file.\n";
          exit;
        }
        while (!feof ($file)) {
          $line .= fgets ($file, 4096);
        }
        echo $line;
        fclose($file);
      

  3.   

    php读取word,txt,excel……
      

  4.   

    <form>
    <textarea name="Phone" id="phone" style="margin-top:5px; width:310px;" cols="25" rows="15"></textarea>
    <input type="file" name="fileName" id="fileName">
    <input name="buttonId" name="buttonId" type="button" value="提交">
    </form>
    怎么结合你给的这代码
      

  5.   

    给你一个思路:
    1)你看下file_get_content()和fopen()函数,二者可选择一个,怎么把txt和word读取出来。
    2)怎么把读取的值再绑定到textarea。
    你研究下。