For practical purpose, I don't want to keep all my pictures in my apache /var/www/ directory so I created a symlink to link on my other drive in the project folder. My problem comes when I try to read the symlink with opendir() from PHP. opendir() can't open it. I tested it with my "img" folder since it was a real one and it worked fine. I assume my code is good because of this little test and because most of it comes right from the PHP manual website. Some people say it might be the permissions but to be sure (and since it is only a home project), I decided to allow all permissions and it is not working either. I can assure you that my link isn't broken cause I can access it with bash. Is there a way to fix this problem? And it might be a stupid question I know, but since my knowledge in PHP is limited to the basics...
Here is my function if it can help:
Code: Select all
function getPicturesInList($server_path)
{
// create an array to hold directory list
$results = array();
if ($handle = opendir($server_path))
{
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle)))
{ echo "<tr><td>". $file ."</td></tr>"; }
/* This is the WRONG way to loop over the directory.
while ($file = readdir($handle))
{ echo "$file\n"; }*/
closedir($handle);
}
else // This line is simply for a little test
{ echo '<script>alert("Cant open directory: '. $server_path .'")</script>'; }
return $results;
}
Thanks in advance for any help.
R3nfr3w