"fopen() failed to open stream: Permission denied"
Posted: Sun Nov 23, 2003 1:27 pm
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:
(actually the value "post_charges.txt" is passed in the $filename argument of the above function)
I really appreciate any help...
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);
}
?>I really appreciate any help...