使用php中的HttpOpenFileFromStream
打开edraw文件我在加载事件
上使用此javascript代码document.OA1.HttpInit();
document.OA1.HttpAddpostString("DocumentID", "sample5.docx");
document.OA1.HttpOpenFileFromStream("http://localhost/rte/action_open_file.php", "Word.Application");
php code action_open_file.php
header("http/1.1 200 OK");
$doc_file_name = $_REQUEST["DocumentID"];
$file_size = filesize($doc_file_name);
$file = fopen($doc_file_name,"r");
$data = fread($handle,$file_size);
fwrite($handle,$data);
fclose($handle);
但它在网页中打开空文件,但sample5.docx有一些文字。
答案 0 :(得分:1)
你的JS代码很好。只需使用以下代码替换action_open_file.php
代码:
<?php
$filename = $_REQUEST["DocumentID"];
echo "Get Stream Successfully!";
echo "EDA_STREAMBOUNDARY";
$fp=fopen("$filename","r");
print fread($fp,filesize("$filename"));
fclose($fp);
echo "EDA_STREAMBOUNDARY";
exit();
?>