0

我正在考虑更改我们当前使用 RTF 文件的 Intranet,以便它可以使用 docx。

我们需要能够更改模板,然后将一些来自 Intranet 的数据注入它,并将其保存为 docx 文件。

为此,我找到了 TinyButStrong 插件,它似乎可以做我们想要的。

我已经做了一些测试,并且可以让它将文件保存在与模板相同的文件夹中。但我无法将其保存在其他位置。

它给了我这个错误:

TinyButStrong Error OpenTBS Plugin: Method Flush() cannot overwrite the target file '//SERVER/SHARE/FOLDER/SUBFOLDER/ANOTHER SUBFOLDER/document name.docx'. This may not be a valid file path or the file may be locked by another process or because of a denied permission. The process is ending, unless you set NoErr property to true.

我不认为这是一个前提错误,因为我在处理我们的 RTF 文件的同一个脚本中工作,并且它们被保存在同一个位置,因为我需要这样做。

但我确定只有我一个人没有正确理解 TinyButStrong,那么如何让它保存在动态文件路径上呢?

以下是我尝试处理动态文件路径的地方。

        $file = "//$SERVER/$KATALOG/".$_GET['type'].$root.$nr."/"; //.$_GET['type'].$nr."R".$rev."-".$sprog.".rtf"; 


    //echo $template;
    $output_file_name = str_replace('.', '_'.date('Y-m-d').$save_as.'.', $filename); 
    echo $output_file_name = $file . $output_file_name;
    if ($save_as==='') { 
        // Output the result as a downloadable file (only streaming, no data saved in the server) 
        $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields. 
        // Be sure that no more output is done, otherwise the download file is corrupted with extra data. 
        exit(); 
    } else { 
        // Output the result as a file on the server. 
        $TBS->Show(OPENTBS_FILE, $output_file_name); // Also merges all [onshow] automatic fields. 
        // The script can continue. 
        exit("File [$output_file_name] has been created."); 
    } 
4

2 回答 2

0

看来您正在使用 TinyButStrong 的 OpenTBS 插件。

OpenTBSfopen($File, 'w')在编写目标文件时只使用 PHP 函数。

您收到的错误消息表明 PHP 未能以写入模式打开此文件的句柄。原因可能多种多样,但您可以使用您提到的文件路径检查自己。

于 2017-06-28T00:38:14.593 回答
-1

我和你的 OPENTBS 一样有同样的错误,就我而言,这很简单,我忘了创建目录文件夹来存储输出文件

于 2018-01-12T03:31:08.580 回答