Click to See Complete Forum and Search --> : rmdir()


madddidley
01-23-2006, 03:59 PM
I have a photo album script that makes a new directory for the images in that album. I can create it fine, delete from it fine. But for some reason I can't delete the directory. I tried it everyway that I thought of, then I went to the actual folder and tried to delete it, it said that this folder is being used by another program. I closed the browser and that didn't work. I even shut down apache and still got the stupid error. Does anyone have any idea what may cause this.

I thought that maybe I should close the directory put I never open it in the code. Any help from you pros would be nice. I can post my code but I think the error is somewhere else.


Edit: I think it may be the way I'm creating the directory? But I'm not doing anything special.
mkdir("C:\Apache2\htdocs\iblogger\imageUploads/$directory", 0777);



Thanks,
Matt

bokeh
01-23-2006, 05:04 PM
What platform is this on?

madddidley
01-23-2006, 07:42 PM
Well I am running Apache/2.0.54 (Win32) PHP/5.0.4

My friend set it up on my computer due to the fact that I don't know much about the server stuff. I only know a little about some of the things in the php.ini

Did that even answer your question?

bokeh
01-24-2006, 05:34 AM
Well I ran a test on the same apache/php combination and I can't duplicate the error. <?php

$dir_self = $_SERVER['DOCUMENT_ROOT'].str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
$dir = $dir_self.'testdir/';
$file = $dir.'test.txt';
mkdir($dir) or die("I could not create <i>{$dir}</i>");
is_dir($dir) or die("<i>{$dir}</i> does not appear to exist");
file_put_contents($file, 'testing...') or die("I could not create <i>{$file}</i>");
file_get_contents($file) or die("I could not open <i>{$file}</i>");
unlink($file) or die("I could not delete <i>{$file}</i>");
!is_file($file) or die("<i>{$file}</i> was not deleted");
(!($files = glob($dir."*.*"))) or die(print_r($files).' Files still exist in that directory');
rmdir($dir) or die("I could not remove <i>{$dir}</i>");
echo 'all went ok';

?> One of the above lines might find the error... but for me it just returns all went ok.

madddidley
01-24-2006, 12:22 PM
Well when the code gets executed there is no error but it doesn't delete the folder. I get the error when I try to manually delete the folder. I'll try that and poke around a little more.

Thanks

chazzy
01-24-2006, 12:54 PM
umm so you're getting an error when you try to manually delete the folder? Looks like it might be a permission/ownership issue.

bokeh
01-24-2006, 01:20 PM
Looks like it might be a permission/ownership issue.On Windows XP?

madddidley
01-24-2006, 02:57 PM
I figured it out. Windows creates a Thumbs.db file and in the explorer I changed turned on "Do not cache thumbnails" in the view tab. I couldn't delete because that file was still in the directory. Thanks, if it wasn't for that test code I probably wouldn't have noticed that for a while.

Thanks

chazzy
01-24-2006, 03:56 PM
On Windows XP?

Yes, depending on where the directory resides.

Try if you want, create a second user on your xp install (provided you have one) and log in as them. Try to access the administrator's documents (or any other user's for that matter).

bokeh
01-24-2006, 05:15 PM
Yeah but Apache is running as a service so it has the same permission as an administrator account and can access every file on the machine (unless there is an open_base_directory restriction in force from php.ini). Maybe I should get my Linux server running.