"fopen() failed to open stream: Permission denied"

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
vasilis
Forum Commoner
Posts: 40
Joined: Tue Apr 22, 2003 7:37 am

"fopen() failed to open stream: Permission denied"

Post by vasilis »

I am testing from my local browser a php project on a remote testing server. I am trying to write the contents of an array ($arrayname) into a text file ($filename) (on the remote server which runs on Linux and php 4.3.4 with safe mode off) but i get a "fopen(post_charges.txt): failed to open stream: Permission denied in /home/testing/public_html/viotopos/admin_fns.php on line 1324"
My code works ok in my local testing computer. I guess it must be some file permission problem on the remote server. THis file's permission status is 644 (even if i try to change it to 666, it doestn change, although i dont think this needs to be done since under 644 status there are user read and write permissions, and I guess the php scripts run as "user"). I have really tried reading all over the board for similar problems but I couldnt solve the problem. Below is the code that im using:

Code: Select all

<?php
function arraytofile_numr($arrayname, $filename)
//returns a file with name "$filename" made out from array "$arrayname"

{
 // echo array elements
        reset ($arrayname);
       $fp=fopen($filename, 'w+');
        while (list(, $value)=each($arrayname)) {
        $inputstr= $value;
        fwrite ($fp, $inputstr);
   }
fclose($fp);
}
?>
(actually the value "post_charges.txt" is passed in the $filename argument of the above function)
I really appreciate any help...
vasilis
Forum Commoner
Posts: 40
Joined: Tue Apr 22, 2003 7:37 am

continued

Post by vasilis »

when I tried to put that file to a separate directory inside or outside the previous directory I get a "fopen http://localhost/viotopos/dict/post_charges.txt): failed to open stream:HTTP wrapper does not support writeable connections" error php message.
Post Reply