dongzhi8487 2011-08-04 08:22
浏览 149

无法使用fopen()打开远程XML文件。 我需要在服务器中设置的所有权限或者我需要在fopen()函数中设置的参数。

I am trying to open an XML file in remote server through fopen() function. I have two remote servers and the file permission of the xml is set to 777 in both servers. i am able to open the xml from one server , but not from other. Both files can be opened in browser.

What all permission i need to set or what parameters i need to set in fopen() function.?

this is the function

function getFileData($ProjectName)
{
    $file = fopen($ProjectName, "r") or exit("Unable to open File! ".$ProjectName);
    $fileContent="";
        while(!feof($file))
          {
         $fileContent.=fgets($file);
          }
    fclose($file);
    echo $fileContent;
}

getFileData('http://serverA.com/myxml.xml'); // gives the content
getFileData('http://serverB.com/myxml.xml'); // gives the error fopen(http:/serverB.com/myxml.xml) [function.fopen]: failed to open stream: HTTP request failed!
  • 写回答

3条回答

  • douzhan4522 2011-08-04 08:25
    关注

    You only have one / after http: in the last two lines - but I doubt that's the problem. Can you open the file in the browser?

    Perhaps try using file_get_contents . It does the same as your function, except it's ready made and fully tested by the PHP guys.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作