[nycphp-talk] phantom file writing errors
John Lacey
jlacey at att.net
Tue Jul 27 09:33:36 EDT 2004
Marc Antony Vose wrote:
> It's creating directories inside a directory that is chmod 777. Into
> each directory is placed an HTML file, which is created in the code
> below. Therefore, all of the directories and files involved are owned
> by the script that is being run (user: apache, grp: apache), since the
> files didn't even exist in the first place. And it's definitely writing
> to the file, because the contents of the files are there.
Sorry, but I didn't see in the previous posts that file contents are
there in addition to the files themselves--and from the above, you
obviously didn't need the basic info I posted.
I don't know what other steps you've taken to troubleshoot, but I often
isolate a code snippet and try different things to see if anything
changes. You may have already gone thru this exercise, but if not--in
your code:
// output the file
$output_h = fopen($output_path,"w");
fwrite($output_h,$output);
fclose($output_h);
what would this yield?
// output the file
$filedata = 'some stuff';
$fh = fopen("/path/filename", "w");
fwrite($fh, $filedata);
fclose($fh);
If the above worked, then I'd take a closer look at how the outputdir
and outputdata is being created. In addition, what happens if an
existing file is opened for reading and fread(), or fopen() mode is
changed to append instead of write? Does a print_r() on the $fh
($output_h) show a good resource type before the fclose()?
John
More information about the talk
mailing list