[SOLVED] Cant create file in LINUX environment

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

[SOLVED] Cant create file in LINUX environment

Post 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);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Have you done a "ls -l" to check the chmod worked? How did you do the chmod?
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Post 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 ??
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Post by winsonlee »

sorry .. it is the apache permission problem ..

$ fs sa . apache write


i solved it wif the following command.
Post Reply