I am attempting to email an XML file within the uploads folder during my Wordpress directory. This XML must update every time the customer updates or produces a brand new publish utilizing a custom publish_type I produced.

This is actually the code:

<?
add_action( 'save_post', 'producers_xml' );

function producers_xml(){

 if ($_POST['post_type'] == 'producer') 
 {
   $xml = new SimpleXMLElement('<xml/>');
   $producers = get_posts( array( 'post_type'=>'producer', 'numberposts'=>-1 ) );

   $xml->addChild('producers');

   foreach($producers as $i=>$producer){
     $name = get_the_title($producer->ID);
     $owner = get_post_meta($producer->ID, '_producer_contact_name', true);
     $phone = get_post_meta($producer->ID, '_producer_phone', true);
     $fax = get_post_meta($producer->ID, '_producer_fax', true);
     $email = get_post_meta($producer->ID, '_producer_email', true);
     $website = get_post_meta($producer->ID, '_producer_website', true);
     $address = get_post_meta($producer->ID, '_producer_address', true);

     $xml->producers->addChild('producer');
     $xml->producers->producer[$i]->addChild('name', $name);
     $xml->producers->producer[$i]->addChild('owner', $owner);
     $xml->producers->producer[$i]->addChild('phone', $phone);
     $xml->producers->producer[$i]->addChild('fax', $fax);
     $xml->producers->producer[$i]->addChild('email', $email);
     $xml->producers->producer[$i]->addChild('website', $website);
     $xml->producers->producer[$i]->addChild('address', $address); 
 }

 $file = '../../../uploads/producers.xml';
 $open = fopen($file, 'w') or die ("File cannot be opened.");
 fwrite($open, $xml->asXML());
 fclose($open); 
}

?>

The issue I'm getting is it keeps giving me the "File can't be opened up." error which i provided. My uploads folder (and all sorts of enclosed products) have full permissions (777). I have examined my code in your area and delay pills work, however i can't have it to spread out that file around the remote server. I do not have root use of it and so i can't change permissions on anything before httpdocs.

I ought to also point out that fopen is enabled around the server.

EDIT: allow_url_fopen is enabled but allow_url_include is disabled.

Anybody understand what my issue is?

Thanks

Use a complete path (full path), alongside other inspections 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); 
}