Write to XML file using fopen in Wordpress

后端 未结 1 1744
庸人自扰
庸人自扰 2021-01-27 03:10

I\'m trying to write to an XML file in the uploads folder in my Wordpress directory. This XML needs to update each time the client updates or creates a new post using a custom p

1条回答
  •  孤独总比滥情好
    2021-01-27 03:52

    Try using an absolute path (full path), alongside other checks see:

     $file = 'home/my/path/uploads/producers.xml'; //Absolute path
    if(is_file($file) && is_readable($file)){
     $open = fopen($file, 'w') or die ("File cannot be opened.");
     fwrite($open, $xml->asXML());
     fclose($open); 
    }
    

    0 讨论(0)
提交回复
热议问题