astralaaron Posted January 25, 2008 Report Share Posted January 25, 2008 "Warning: rmdir(container/a479a5d4b31979) [function.rmdir]: Directory not empty in C:\wamp\www\siteb\admin\pictures\adm_del_gal_s3.php on line 82Container not deleted"I get this error when trying to rmdir() that has photos in it, i thought it would delete all the photos for me but i guess not...is there some easy way to delete all the photos? or do I have to loop an unlink() and delete them all seperately? Link to comment Share on other sites More sharing options...
jeffman Posted January 26, 2008 Report Share Posted January 26, 2008 I haven't used it (because I have a similar routine in perl), but this page describes a method that looks right. You have to scroll a little.http://www.php.net/unlink Link to comment Share on other sites More sharing options...
astralaaron Posted January 26, 2008 Author Report Share Posted January 26, 2008 I just made it so it did a loop and unlink()'d all the files then had it do the rmdir()it works fine Link to comment Share on other sites More sharing options...
jhecht Posted January 26, 2008 Report Share Posted January 26, 2008 Yeah, the only way to do it is to delete all of the files first, most people generally like to create a function of their own for this kind of thing. If you'd like i could give you one, but the way you're doing it is pretty much the same way I would. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 28, 2008 Report Share Posted January 28, 2008 The function should be recursive. If you find a subdirectory inside the folder then you also need to delete all of the files and folders in that as well, even if there are 100 levels of folders deep. A recursive function will do that. function delete_dir($dir){ if (!is_dir($dir)) return false; $info = scandir($dir); foreach ($info as $chunk) { if ($chunk != "." && $chunk != "..") { $chunk = $dir . DIRECTORY_SEPARATOR . $chunk; if (is_dir($chunk)) delete_dir($chunk); else unlink($chunk); } } rmdir($dir); return true;} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now