Jump to content

failed to open stream: Permission denied in /var/www/p/phj.php


Recommended Posts

I keep getting this error 

Warning: fopen(img/120300.png): failed to open stream: Permission denied in /var/www/play/playall.php on line 192 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/play/playall.php on line 193 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/play/playall.php on line 194 Warning: file_get_contents(img/120300.png): failed to open stream: No such file or directory in /var/www/play/playall.php on line 196 Fatal error: Call to undefined function imagecreatefromstring() in /var/www/play/playall.php on line 197 

with Apache 2 and PHP 5.3 on

Debian GNU/Linux 6.0 (Squeeze)

The script your using is wanting trying to write data to img/120300.png. So you need to give the file 120300.png sufficient write permissions. If it is creating the file 120300.png then you need to give the img/ folder sufficient write permissions.

 

The following wiki article may help

https://wiki.debian.org/Permissions

Some code is causing that.

here is line 192

$fh = fopen($path, 'x');

here is code

$abc=curl_exec($ch);
 $name=rand(0, 999999);
		$path='img/'.$name.'.png';		
		
$fh = fopen($path, 'x');
fwrite($fh, $abc);
fclose($fh);

$st=file_get_contents($path);

PHP supports chmod() .

 

Only works if you're root or the file owner which couldn't be the case or no need to chmod() it.

 

ShviaGupta?  Does the img/ dir exist?  You need to look into Linux file permissions and check the dir if it exists to make sure the Apache user (probably apache or www-data or something) has write permissions.

@Shiva, by default the owner of "www" directory is "root", don't do this!  Is it a public or local server?

this is a local server and i want to use for my pertional use n only for me..........but can i use in public   server?

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.