FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Opendir not working right for me.





Dougie1
I am having a problem with this hopefully someone can help. I think the easiest way is to show you the code:

<?php
$path
= "/videos/";
$dh = @opendir($path) or die("Couldn't open");
$i=1;
while ((
$file = readdir($dh)) !== false) {
if(
$file != "." && $file != "..") {
echo
"$file";
$i++;
}
}
closedir($dh);
?>

It seems fine to me and all it does is say "Couldn't open" and the directory exists (I have checked with is_dir()) It also does contain files.

If it makes a difference I am using frihost and when I take the error suppressing part off it gives the following error:

Code:
Warning: opendir() [function.opendir]: open_basedir restriction in effect. File(/adminvideos/) is not within the allowed path(s): (/home/dougie1/:/tmp/:/var/tmp/:/var/www/:/usr/local/lib/php/:/etc/virtual/) in /home/dougie1/domains/dougs-site.frih.net/public_html/Admins Favorites.php on line 3

Warning: opendir(/videos/) [function.opendir]: failed to open dir: Operation not permitted in /home/dougie1/domains/dougs-site.frih.net/public_html/Admins Favorites.php on line 3

Warning: readdir(): supplied argument is not a valid Directory resource in /home/dougie1/domains/dougs-site.frih.net/public_html/Admins Favorites.php on line 5

Warning: closedir(): supplied argument is not a valid Directory resource in /home/dougie1/domains/dougs-site.frih.net/public_html/Admins Favorites.php on line 11
MrBlueSky
You can't just access any directory on frihost. That wouldn't be very secure, right? Very Happy

But I think you want to access the subdirectory videos of your own homedir.
If so, use:

Code:

$path = "videos/";
Related topics
E-Cards with PHP & MySQL
Your opinion about ColdFusion
Donutey, Version 3
Firefox 1.5 beta 1 released
free hosting
My Sonic Website
Not Voting is Reasonable for People Who Want Freedom
Job that u wouldn't mind doing for the rest of your life
My Computer Keeps Freezing Up When It Loads Too Much...?
My website
which is better
"Buddha knows all answers!"
PHP Not Working on Localhost
Water from the tap of kitchen sink not working right
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.