【问题标题】:TinyButStrong and dynamic file pathTinyButStrong 和动态文件路径
【发布时间】:2017-06-27 14:51:14
【问题描述】:

我正在考虑更改我们当前使用 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."); 
    } 

【问题讨论】:

    标签: php opentbs tinybutstrong


    【解决方案1】:

    您似乎正在使用 TinyButStrong 的 OpenTBS 插件。

    OpenTBS 在写入目标文件时仅使用 PHP 函数 fopen($File, 'w')

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

    【讨论】:

    • 是的,我正在使用OpenTBS插件,但我不能一直跟着你。我有这段代码,它正在工作。 if ($diverse != "forkal"){ $fp = fopen($file, 'w'); fputs($fp, $输出); fclose($fp);基本上我试图摆脱它,并改用 OpenTBS 但我猜我提供的 output_file_name 是错误的
    • 要进行可靠的调试,请在 $TBS->Show(OPENTBS_FILE, $output_file_name) 之前尝试您的 sn-p $fp = fopen($file, 'w') 并使用相同的变量 $output_file_name
    • 如果在 $TBS->Show(OPENTBS_FILE, $output_file_name) 行之前插入行 $fp = fopen($output_file_name, 'w'); fwrite($fp, "hello"); fclose($fp); exit "ok"; juste 会有什么结果?你有预期的文件和输出文本吗?
    • 如果我插入 $fp = fopen($output_file_name, 'w'); fwrite($fp, "你好"); fclose($fp);退出(“确定”);它会输出“ok”,但不是文件
    • 这个结果表明没有 PHP 能够写入文件 $output_file_name。您必须解决此问题才能获得 TBS 合并结果。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2014-01-10
      • 2021-06-24
      • 2018-02-09
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2018-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多