encolpio
Joined: 24 Jan 2007 Posts: 1
|
Posted: Wed Jan 24, 2007 6:14 am Post subject: VFS Virtual File System - failed to open stream |
|
|
Hi, I'm trying to use VFS, and have this problem:
| Quote: | | Warning: file_get_contents(/home/mario/Desktop/prueba.txt) [function.file-get-contents]: failed to open stream: Permission denied in /usr/share/php/VFS/sql_file.php on line 72 |
Here is the code of /usr/share/php/VFS/sql_file.php:
| Code: | function read($path, $name)
{
$conn = $this->_connect();
if (is_a($conn, 'PEAR_Error')) {
return $conn;
}
$file = $this->_getNativePath($path, $name);
if (function_exists('file_get_contents')) {
$data = file_get_contents($file); //this is line 72 in that file
} else {
$fp = @fopen($file, 'rb');
if (!$fp) {
return PEAR::raiseError(_("Unable to open VFS file."));
}
$data = fread($fp, filesize($file));
fclose($fp);
}
return $data;
}
|
I used data/vfs.sql to create the "vfs" table in the "vfs" database in mysql.
I can see I have a problem with permissions but don't know how to work it out.
The file I want to read is "/home/mario/Desktop/prueba.txt", and my code is:
| Code: | <?php
require_once('HTML/Template/Sigma.php');
require_once('VFS.php');
require_once('VFS/sql_file.php');
$array = array(phptype => 'mysql',
vfsroot => '',
table => 'vfs',
hostspec => 'localhost',
database => 'vfs',
username => 'mario',
password => '',
);
$vfs = new VFS_sql_file($array);
$vfs->_permissions = array(
'owner' => array('read' => true, 'write' => true, 'execute' => true),
'group' => array('read' => true, 'write' => true, 'execute' => true),
'all' => array('read' => true, 'write' => true, 'execute' => true));
$res = $vfs->read('/home/mario/Desktop/', 'prueba.txt');
echo "Resultado: " . $res;
?> |
Any idea? |
|