Warning: fopen(*.txt) [function.fopen]: failedto open stream

need help keep getting this error message

Warning: fopen(*.txt) [function.fopen]: failed to open stream: Permission denied
Warning: fwrite(): supplied argument is not a valid stream resource in

any advice



    foreach($fileList as $file)
        if(ereg("tar$", $file))
            $tarfile = new Archive_Tar(LOCAL_WORKING_DIR . $file);
            $tarfile->extract(LOCAL_WORKING_DIR); //or die("Could not extract files from " . LOCAL_WORKING_DIR . $file);
            echo "Succesfully unacked " . $file . "<br>n";
        else if(ereg("gz$", $file))
            $handle = fopen(LOCAL_WORKING_DIR . substr($file, 0, -3), "w+");
            $lines = gzfile(LOCAL_WORKING_DIR . $file);
            foreach ($lines as $line) {
                fwrite($handle, $line);
            echo "Succesfully unacked " . $file . "<br>n";

plz check the line no.

the code u provieded semes to be OK. the regex shoulgnt let “*.txt” be passed to fopen.

try to find the line realy taking “*.txt” as argument for fopen. as fopen isn’t able to process wildkards, it has to fail.

where does “*.txt” come from? user input?

Here is the exact error message

Warning: fopen(./temp/features.txt) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts/&&&&&.com/httpdocs/img/index.php5 on line 203

Warning: fwrite(): supplied argument is not a valid stream resource in /var/www/vhosts/&&&&&.com/httpdocs/img/index.php5 on line 206

line 203 is $handle = fopen(LOCAL_WORKING_DIR . substr($file, 0, -3), “w+”);

line 206 is fwrite($handle, $line);

thanks for the help

some sry’s

sry, i didn’t understant ur short form of the error

sry, i have to ask some more questions:

  • is /var/www/vhosts/&&&&&.com/httpdocs/img/temp/features.txt realy existing? (i know it might be a dumb question, but i have to ask)
  • what kind of acces do u have to the server? local? ssh? ftp?
  • are u fmilar with unix rights (ugo rwx)
  • if u have access to this *nix-rights what value/uid/gid do they have?

hope u are able to aswer some of that questions (if not, don’t care and just, tell us what u know).

last bur not least: prmissons are dificult, if u are nor familar with it. any info hopefully helps us to help u.

I would agree with Q1712, you probably need to do a chmod on the file. The error is saying the script doesn’t have permission to write to the file and without that access it isn’t able to write anything. That is also why you are getting fwrite() warning.

Sponsor our Newsletter | Privacy Policy | Terms of Service