PHP "copy" not working on my Server

Hi, I have a flash movie that sends data to PHP and it writes data to an XML file, when the XML file reaches a certain size then PHP makes a copy of the XML and saves it with a new name. PHP then clears the XML and the whole process begins again.

I´ve tried this on my Wamp test Server and it works perfectly there, but now when I’m trying this on a real server the copy function dosn’t work, it just cleans the old XML file when the XML file gets too big. It does not save the old data to a new file …

Could this have something to do with the users permission on the server???

Can someone help me?

 
<?php 
$filename = "xmldata/egTest1Data.xml"; 
$raw_xml = file_get_contents("php://input"); 
$clean_xml = '<?xml version="1.0"?><Tracks></Tracks>'; 


print $raw_xml; 


//Check File Size. The size returned is in BYTES:------------- 
$size = filesize($filename); 

//If XML file is larger than 100KB's then make a copy. 
if($size > 102400){ 

    //Write normally the last entry:--------------------------- 
    $fp = fopen($filename, "w"); 
    fwrite($fp, $raw_xml); 
    fclose($fp); 

    //Copy file with new name containing the day it was copied 
    $today = date("YmdHi"); 
    $newFile = "xmldata/egTest1Data".$today.".xml"; 
    copy($filename, $newFile); 
      
    //Overwrite file to clean XML------------------------------ 
    $fp = fopen($filename, "w"); 
    fwrite($fp, $clean_xml); 
    fclose($fp); 


} else { 
    //Write normally:------------------------------------------ 
    $fp = fopen($filename, "w"); 
    fwrite($fp, $raw_xml); 
    fclose($fp); 
} 
?>