Hi All,
I am trying to add an RSS feed to my site by following the instructions in issue 30 of Practical Web Projects. (UK Magazine)
All seems okay except that writing the rdf file to disk is failing, which may be a problem with file permissions in IIS.
I have turned on Read and Write permissions, and have tried various paths including $DOCUMENT_ROOT (set in php.ini), but no joy.
The relevant function is as follows:
[FONT=Courier New]function getFeed($feed, $feedname, $no) {
global $aDisplay, $numRows;
$numRows =$no;
$tmp = "$DOCUMENT_ROOT/mcm/".$feedname."_tmp.rdf";
$expires = time()-3600;
if (!file_exists($tmp) or filemtime($tmp) < $expires) {
@copy($feed, $tmp) or die("File copy to temp file failed");
}
$xml = "";
$filehandle = @fopen($tmp, "r") or die ("Cannot open temporary file");
while(!feof($filehandle)) {
$xml.= fread($filehandle,4096);
}
fclose($filehandle);
$xmlparser = xml_parser_create();
@xml_set_element_handler($xmlparser, "datahandler");
@xml_parse($xmlparser, $xml) or die("Error parsing data file");
xml_parser_free($xmlparser);
return $aDisplay;
}[/FONT]
The code dies with "File copy to temp file failed".
Any ideas?
Thanks,
Brendan