Jump to content

How to create a file,[function.fopen]: failed to open stream: Permission denied


g_p_java

Recommended Posts

Hello ,

 

i have the following code

 


$newfile="/home/newfile.txt";

$file = fopen ($newfile, "a");

$output = $ip." ".$newString . "\n";

fwrite($file, $output);

fclose ($file);

 

Well, in order for the code to run , the file newfile.txt shall exist from the beginning in my root directory.

If there is no file named newfile.txt, the php cannot create it at that time but it outputs :

 

Warning: fopen(/home/newfile.txt) [function.fopen]: failed to open stream: Permission denied in /home/index.php on line 70

 

What shall i do?

The program runs only if the  file exists.

 

Thanks in advance!

Don't you need to changes the folder permissions through FTP?

 

 

Hm...i'm using Unix, I haven't thought of it, cause when the file already exists the fopen works fine, do you know what shall i do in order to change the folder permissions?

Well, there is a command named chmod but i know how to use it only when a folder already exists e.g. chmod 755 php_folder

but i don't know generally how i can do that

Do you have any idea?

 

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.