fopen() create file problems
Posted: Sun May 25, 2008 9:32 pm
hey all - i´m new to php and having trouble writing a simple code which should create a file. here is the most simplified version:
***** PLEASE USE CODE OR PHP TAGS WHEN POSTING SCRIPTS *****
if test.txt exists the code works perfect. but if there isn't already a test.txt file it gives this error:
Warning: chmod() [function.chmod]: No such file or directory in /home/littlesc/public_html/bms/simple.php on line 4
error, test.txt
I assume this is a permission thing but my permission for the directory is set to 755 - this should be ok right?
thanks.cheers.brook
***** PLEASE USE CODE OR PHP TAGS WHEN POSTING SCRIPTS *****
Code: Select all
<?php
$content = "my content";
$path = "test.txt";
if(!chmod($path, 0744)) {
echo "error, $path";
exit;
} else {
$file = fopen($path, "w+");
}
if(fwrite($file, $content)) echo "writing=Ok";
else echo "writing=Error";
fclose($file);
?>
Warning: chmod() [function.chmod]: No such file or directory in /home/littlesc/public_html/bms/simple.php on line 4
error, test.txt
I assume this is a permission thing but my permission for the directory is set to 755 - this should be ok right?
thanks.cheers.brook