[thelist] php - cannot open or write to a file - solved

Bob Meetin bobm at dottedi.biz
Sun Jul 19 19:34:00 CDT 2009


Dave Stevens wrote:
> Maybe the directory doesn't have wrote permissions?
>
> Sent from my iPhone
>
> On 19 Jul 2009, at 17:01, Bob Meetin <bobm at dottedi.biz> wrote:
>
>> $file = "/var/www/some_username/httpdocs/survey.csv";  // the path is
>> accurate
>>
>> if (! file_exists( $file )) { $doit = fopen("$file", "w"); }
>> $fp = fopen("$file", "a+");
>> $label = "some text"
>> fwrite($fp, "$label|");
>> fwrite($fp, "XXXXXXXXXXXXXXXXXXXXX");  // just to see...
>>
>> Thhe above looks to me that it should work, however of course it doesn't
>> so I tried a couple things like the following in the PHP script:
>>
>> system ("touch $file"); // it just stares back at me
>>
>> So I ftp a one liner file to the website and:
>>
>> chmod ("$file", 0666); // this does nothing to update perms
>>
>> system ("ls -l $file"); // this lists the file and perms
>>
>> system ("chmod 666 $file"); // this also does nothing
>>
>> I'm thinking this must be a probelm with how the "UNIX/Linux" webserver
>> is set up, so I ftp a phpinfo() file to the server What would they have
>> done with apache/php.ini to prevent file creation, and if so what should
>> I be looking for?
>>
>> -- 
>> Bob0:
-->> that was a hint, but not the directory;  I forgot that through FTP 
you can not only look at but change file permissions.  The httpdocs 
directory is 750:

drwxr-x---  19 rvcftp   psaserv     12288 Jul 19 11:49 httpdocs

And the file was what it normally should be, 644, to write to files:

-rw-r--r--   1 rvcftp   psacln        816 Jul 19 17:26 survey.csv

On a hunch with your clue I changed it to 666 via FTP and it works!

-Bob






More information about the thelist mailing list