2016-02-11 15:05
浏览 270

PHPWord - 无法打开已保存的文件,因为没有“访问权限”

Im using PHPWord to make a document from a template, its all worked great so far and the documentation is fairly decent:

But I cannot open the file that I have created, using:


It says word cannot open as user does not have access privileges. I don't see anything in the documentation about this and searching SO finds several other similar questions all unanswered.

Anyone have any ideas on this?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doudilin1225 2016-02-11 16:19

    Ok I worked it out. Thanks to @John Smith for helping to steer me in the right direction. I found the answer here:

    Basically i changed the function saveAs from:

    rename($tempFilename, $strFilename);


    copy($tempFilename, $strFilename);

    and it now works a dream. Thanks again @John Smith for the help.

    打赏 评论
  • doupinyan0186 2016-02-11 15:49

    You can do this manually I think :

    // Read and write for owner, read for everybody else
    chmod("/somedir/somefile", 0644); 
    打赏 评论

相关推荐 更多相似问题