PHPWord中模板处理器的默认目录是什么?



我正在使用PHPword来生成word文档。我想生成多个文档,以便我想使用模板。我在控制器中尝试了以下代码:

$templateProcessor = new TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
$templateProcessor->setValue('Name', 'John Doe');
$templateProcessor->setValue(array('City', 'Street'), array('Detroit', '12th Street'));

并显示以下错误:

copy(resources/Sample_07_TemplateCloneRow.docx): failed to open stream: No such 
file or directory

在:

// Template file cloning
if (false === copy($documentTemplate, $this->tempDocumentFilename)) {
throw new CopyFileException($documentTemplate, $this->tempDocumentFilename);
}

模板处理器的默认目录是什么?或者我们必须手动给出位置。请帮忙!

PHP版本:7.0 拉拉维尔 5.5 PHP版本:0.14

这对我有用: Sample_07_TemplateCloneRow.docx改为在/storage 目录中。并使用此行:

$templateProcessor = new 
TemplateProcessor(storage_path('Sample_07_TemplateCloneRow.docx'));

最新更新