PHP: Creating file in different directory

Hello, I’m putting together an XML file using the following code, and it works 100%, but creates the file in the dir the script ran in.


$myFile = urlencode(strtolower($location) . ".xml");
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "<states>
");
fwrite($fh, "<state name=\"$location\" colour=\"#8800ff\">
");
foreach ($repDelID as $val) {
$y += 1;
$strpos = strpos($repDelID[$y-1], ',');
$val = "<point lat='" . substr($repDelID[$y-1], 0, $strpos) . "' lng='" . trim(substr($repDelID[$y-1], $strpos+1)) . "' />";
fwrite($fh, " " . $val . "
");
}
fwrite($fh, "</state>
");
fwrite($fh, "</states>
");
fclose($fh);

I want it to create the file in another dir called ‘xmlfiles’. It’s in the same dir as the script, and is writeable. The following code does not work:


$myFile = "\\xmlfiles\\" . urlencode(strtolower($location) . ".xml");
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "<states>
");
fwrite($fh, "<state name=\"$location\" colour=\"#8800ff\">
");
foreach ($repDelID as $val) {
$y += 1;
$strpos = strpos($repDelID[$y-1], ',');
$val = "<point lat='" . substr($repDelID[$y-1], 0, $strpos) . "' lng='" . trim(substr($repDelID[$y-1], $strpos+1)) . "' />";
fwrite($fh, " " . $val . "
");
}
fwrite($fh, "</state>
");
fwrite($fh, "</states>
");
fclose($fh);

Please help!