napalm Posted July 11, 2008 Share Posted July 11, 2008 Alright well i got this script that counts how many files are in a users directory you see? But if a user hasn't uploaded yet, lets say if there new then they don't have a folder yet because we have it set up your folder gets created when you upload files.. Theres a big ol' error because it cant find that users directory.. the script im using to count files. <?php $gallery = opendir($whichSection . "upload/v2/" . $member_data['username'] . "/"); $counter = 0; while($file = readdir($gallery)){ if($file != '.' && $file != '..'){ $counter++; } } closedir($gallery); echo($counter); ?> The error it shows Warning: opendir(upload/v2/theusername/) [function.opendir]: failed to open dir: No such file or directory in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 267 Warning: readdir(): supplied argument is not a valid Directory resource in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 269 Warning: closedir(): supplied argument is not a valid Directory resource in /home2/battlege/public_html/pivothost/animatorhost/apanel3.php on line 274 0 / 1500 i was wondering if there was away if there is not a a directory created yet or if its "not found" is there a way to display content stating so? im not the best php person ever but i tried }else{ echo("Not Found!"); } No work Well if some one could help it be great! Thanks! NapalM Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 why not build the DIR on the user account creation??? Quote Link to comment Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 That would mean having to make 7000 dirs my freind Quote Link to comment Share on other sites More sharing options...
corbin Posted July 11, 2008 Share Posted July 11, 2008 http://us3.php.net/manual/en/function.file-exists.php Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 then look into virtual directories using a database Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 11, 2008 Share Posted July 11, 2008 don't use file_exists( ) Use this: if( !is_dir( $stuff ) ) { die( "Not Found!" ); } You don't nescessarily have to die(), but I think you get the gist... Quote Link to comment Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 could you possible edit it? it will be appreciated thanks! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2008 Share Posted July 11, 2008 I've used .htaccess mods + mysql to create a virtual file system that is seamless to the user other than the fact that FTP and other classical methods fail. Quote Link to comment Share on other sites More sharing options...
auro Posted July 11, 2008 Share Posted July 11, 2008 Ya use is_dir($somedir) to determine if a folder exists and then print an error accordingly Quote Link to comment Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 Where do i put it there? ??? Can u edit the script i put to do that? Quote Link to comment Share on other sites More sharing options...
corbin Posted July 11, 2008 Share Posted July 11, 2008 Hehe forgot about is_dir ;p. I haven't ever needed to check if a directory exists before. (Although, I have used directory loops before, so I guess I would've used is_dir then.... Damn my memory.) Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 11, 2008 Share Posted July 11, 2008 <?php if ( !is_dir( "upload/v2/" . $member_data['username'] . "/" ) ) { die( "Directory Not Found!" ); } $gallery = opendir($whichSection . "upload/v2/" . $member_data['username'] . "/"); $counter = 0; while($file = readdir($gallery)){ if($file != '.' && $file != '..'){ $counter++; } } closedir($gallery); echo($counter); ?> Quote Link to comment Share on other sites More sharing options...
napalm Posted July 11, 2008 Author Share Posted July 11, 2008 alright that seems to work i see it adds some probs to my template ill figure that out. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.