[英]PHPword cannot open stream
I have task that I am loading Tinymce Editor to my browser and edit it. 我要执行的任务是将Tinymce Editor加载到浏览器并进行编辑。 After editing I am trying to save the editor value into Microsoft format and for this purpose I use Phpword class .
编辑之后,我试图将编辑器值保存为Microsoft格式,为此,我使用Phpword类。 I include the file path but I can't there is a fatal error said that require_once(../PhpWord.php): failed to open stream: No such file or directory.
我包括文件路径,但我不能出现致命错误,说require_once(../ PhpWord.php):无法打开流:没有这样的文件或目录。 I already put the Phpwrd.php in the directory that I am tring to access
我已经将Phpwrd.php放在我要访问的目录中
my code is 我的代码是
require_once '../PhpWord.php';
$PHPWord = new PhpWord();
$section = $PHPWord->createSection();
// After creating a section, you can append elements:
$section->addText($data);
// At least write the document to webspace:
$$objWriter->save('helloWorld.docx');
The Error you are having is because PHP cannot find "PhpWord.php". 您遇到的错误是因为PHP无法找到“ PhpWord.php”。 the code you gave it - '../PhpWord.php' will look in the parent directory of your current directory.
您提供的代码-“ ../PhpWord.php”将在当前目录的父目录中查找。
I have never had any good luck with relative paths and the require statement. 我从来没有过相对路径和require语句的运气。 PHP prefers a full path when using require_once.
使用require_once时,PHP倾向于使用完整路径。 If you want to find the file using a full path within your own drectory you will use
如果要在自己的目录中使用完整路径查找文件,则将使用
require_once(dirname(__FILE__) . "/PhpWord.php");
if you want to look for the file a directory abov, you will use 如果要在文件的目录中查找,请使用
require_once(dirname(dirname(__FILE__)) . "/PhpWord.php");
I hope this helps. 我希望这有帮助。 Good Luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.