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
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); }