Page 1 of 1

[SOLVED] Cant create file in LINUX environment

Posted: Sun Aug 28, 2005 7:32 pm
by winsonlee
The following code works fine in my windows platform. Somehow when i run it in linux, it says that "cant open file write". I have chmod the directory that the files resides on to 777. Although the directory is chmod to 777 but somehow the file cannot be created. any idea why ???

Code: Select all

$myFile =  $date. ".txt";
$fh = fopen($myFile, 'w') or die("can't open file write");

$bodywrite = $bodywrite . "footer(".date("H:i").")"; 
fwrite($fh, $bodywrite);
fclose($fh);

Posted: Sun Aug 28, 2005 7:57 pm
by feyd
although irregular, try: fopen($myFile, 'wb')

I'd suggest you set your error_reporting level to E_ALL, which will help tell you what's wrong.

Posted: Sun Aug 28, 2005 8:02 pm
by Chris Corbyn
Have you done a "ls -l" to check the chmod worked? How did you do the chmod?

Posted: Sun Aug 28, 2005 8:11 pm
by winsonlee
I tried wb but it doesnt seems to be working as well


chmod 777 PROJECT

that is how i chmod my main directory.

any clue what went wrong ??

Posted: Sun Aug 28, 2005 8:23 pm
by Chris Corbyn
Is the file you're trying to create in that exact folder or a subfolder? I hope this doesn't sound too patronising (sorry if it does - it's not intended) but did chmod give any output at all? (text on screen).

If it's in a subfolder either chmod the actual folder OR do a chmod recursive (chmod -R 0777 folder_name).

BTW.... (i think) you need to make sure you do 0777 and not 777

Posted: Sun Aug 28, 2005 8:30 pm
by winsonlee
sorry .. it is the apache permission problem ..

$ fs sa . apache write


i solved it wif the following command.