By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

Subject: failed to open stream: Permission denied

100+
P: 118
Hi,

when i run my code it gives error as

fopen(lib/providers//provider.RVLogic.php): failed to open stream: Permission denied in F:\Facebook\furniture11\Data Mining\public_html\lib\inc\functions.lib.php

Line 673 : trigger_error("Failed to open stream to $filename. Permission denied!", E_USER_ERROR);

could you plz tell the solution for how to avoid that errors

[PHP]

// Define Needed Function
if(!function_exists('file_put_contents'))
{
if (!defined('FILE_USE_INCLUDE_PATH'))
define('FILE_USE_INCLUDE_PATH', 1);

if (!defined('LOCK_EX'))
define('LOCK_EX', 2);

if (!defined('FILE_APPEND'))
define('FILE_APPEND', 8);

function file_put_contents($filename, $data, $flags = NULL)
{
//if(!file_exists($filename)) trigger_error("File $filename doesn't exist!", E_USER_ERROR);

if(!isset($data)) trigger_error("No value provided for required parameter \$data!", E_USER_ERROR);

if(empty($data) && $data != 0) trigger_error("Empty value passed for parameter \$data!", E_USER_ERROR);

if (FALSE === ($fp = @fopen($filename, $flags & FILE_APPEND ? 'a' : 'wb', $flags & FILE_USE_INCLUDE_PATH)))
{
trigger_error("Failed to open stream to $filename. Permission denied!", E_USER_ERROR);
return FALSE;
}

if ($flags & LOCK_EX)
if (!flock($fp, LOCK_EX))
trigger_error("Exclusive lock to $file was not obtained!", E_USER_WARNING);

$length = strlen($data);
$bytes = 0;

if (FALSE === ($bytes = @fwrite($fp, $data)))
{
trigger_error("Failed to write $length bytes to $filename!", E_USER_ERROR);
return FALSE;
}

fclose($fp);

if($bytes != $length)
{
trigger_error("Only $bytes of $length bytes were written to $filename! Possibly out of disk space.", E_USER_WARNING);
return FALSE;
}

return $bytes;
}
}

[/PHP]
Jul 4 '08 #1
Share this Question
Share on Google+
2 Replies


Markus
Expert 5K+
P: 6,050
You forgot to close the PHP tag: [/PHP]
Jul 4 '08 #2

pbmods
Expert 5K+
P: 5,821
Heya, Swethak.

To avoid this error, you have to modify permissions on the directory that will contain the file in question so that it is writeable by the webserver process.
Jul 4 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.