0
- 我想打开一个Word文档并对其进行编辑
- 我从服务器打开Word文档,在那个时候它与垃圾值开(也许它没有被正确地转换为UTF-8)。
- 当我删除这些垃圾值,并从textarea插入到该文件的东西,它将插入,然后在它打开正确。
- 我想用文档中的英文单词而不是垃圾值打开文档 - 这只是目前打破的第一个开放。
<?
$filename = 'test.doc';
if(isset($_REQUEST['Submit'])){
$somecontent = stripslashes($_POST['somecontent']);
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened fi<form action="" method="get"></form>le.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename) <a href=".$_SERVER['PHP_SELF']."> - Continue - ";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
} else {
// get contents of a file into a string
$handle = fopen($filename, 'r');
$somecontent = fread($handle, filesize($filename));
?>
<h1>Edit file <? echo $filename ;?></h1>
<form name="form1" method="post" action="">
<p>
<textarea name="somecontent" cols="80" rows="10"><? echo $somecontent ;?></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<?
fclose($handle);
}
?>
海感谢这个链接对我很有用 – bhoomi 2010-05-19 06:30:22