Google Search

Google Search

HTML/JavaScript

Thursday, September 1, 2011

File Read,Write,Append,Open,is_writable,fwrite

$filename = '../content.xml';
$somecontent = $content;
`chmod -R a+w content.xml`;

if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}

No comments:

Post a Comment