how to make php create files
Posted: Wed Feb 12, 2003 8:09 am
i can't seem to make php create files on the server (linux with apache 1.3). it acts as if it doesn't have the right to write the file. i use the following script:
on my winXP box home it worked just fine. on the server i uploaded it won't.
anyone can give me any clues?
Code: Select all
<?php
function writedatatodisk($filename, $content)
{
if (file_exists($filename))
{
$delete = @unlink($filename);
}
touch($filename);
chmod($filename,0666);
if (is_writable($filename))
{
if (!$fp = fopen($filename, 'a'))
{
print "Cannot open file ($filename)";
exit;
}
if (!fwrite($fp, $content))
{
print "Cannot write to file ($filename)";
exit;
}
fclose($fp);
}
else
{
print "The file $filename is not writable";
}
}
?>anyone can give me any clues?