php domdocument savexml,php – 使用DOMDocument-> save(‘filename’)保存xml文件时出现问题...

标签:php

我有一个简短的PHP程序,它加载XML文件(test02.xml),然后尝试将其保存在另一个文件中.

该计划是:

//The next three lines are needed to open a file for writing on the server I use.

$stream_options = array('ftp' => array('overwrite' => TRUE));

$stream_context = stream_context_create($stream_options);

$fxml = fopen("ftp://userid:password@www.yurowdesigns.com/public_html/programs/test03.xml","w",0,$stream_context);

//The next three lines create a new DOMDocument, load the input file, "test02.xml"

//and attempt to save the loaded file in the output file "test03.xml"

$doc = new DOMDocument;

$doc->load("test02.xml");

$doc->save("test03.xml");

?>

文件test03.xml正确打开,如果不存在则创建.但是,它没有输出.加载的文件test02.xml是非空的,格式良好的XML.我已经使用其他PHP程序成功加载并读取它.

当我运行上面的程序时,我收到消息:

警告:DOMDocument :: save(test03.xml)[domdocument.save]:无法打开流:第8行/home/yurow/wwwroot/yurowdesigns.com/programs/xmlTest.php中的权限被拒绝.

我在以下位置检查了’save’命令的语法:

phpbuilder.com/manual/en/function.dom-domdocument-save.php

它似乎是正确的.知道是什么导致了这个???

解决方法:

尝试创建文件的用户不是“yurow”(可能有权创建该文件的用户).相反,它是一个用户,如“apache”或“httpd”.通常,系统设置为禁止apache / httpd用户在Web根目录中创建文件.这是为了安全目的而做的,我不建议通过给你的webroot提供apache / httpd写访问来绕过它.相反,您可以在/ home / yurow内部创建文档(只是不在/ home / yurow / wwwroot内).一个例子可能是:/home/yurow/xmldata/test02.xml.您可能需要调整此目录的权限以允许apache / httpd用户写入该目录.

标签:php

来源: https://codeday.me/bug/20190626/1292638.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值