|
Posted by "JesterXL" on 10/20/27 11:25
I have 2 servers; one running *nix w/ PHP4, and one running Windows 2k w/
PHP5; neither of which give me read permissions to write/create text files.
Apparently, the *nix server has PHP in "Power Mode", but I'm still getting
no love from fopen, and chmod via PHP doesn't work.
Any adivce?
Code skrait from the docs:
// Let's make sure the file exists and is writable first.
if(is_writable($filename))
{
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'w'))
{
echo("Cannot open file ($filename)<br />");
exit;
}
$somecontent = " ";
// Write $somecontent to our opened file.
if(fwrite($handle, $somecontent) === FALSE)
{
echo("Cannot write to file ($filename)<br />");
exit;
}
echo("Success, wrote ($somecontent) to file ($filename)<br />");
fclose($handle);
}
else
{
echo "The file $filename is not writable<br />";
if (!chmod($filename, 0666))
{
echo "Cannot change the mode of file ($filename)<br />";
exit;
}
}
Navigation:
[Reply to this message]
|