View Single Post
  #3   Spotlight this post!  
Unread 05-12-2004, 14:46
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: PHP file system stuff

So, I'm trying to remove a directory here...

Windows XP system running Apache 2.0.50 with PHP 4.3.9. (Yes, I know that 2.0.52 is out. Upgrade is coming soon.) I'm trying to remove a directory which is located relative to the current one at ../pages/<dir>. I'm able to delete all the files in the directory, but on trying to remove the directory itself I get a "Permission denied" error.

Here's the exact code which applies:
PHP Code:
...
        
// Ensure the directory only contains the struct file (and the current and parent dir references)
        
if(!(count(scandir("$dir/pages/$_POST[cat]")) <= 3))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
        
        
// Remove struct file
        
if(file_exists("$dir/pages/$_POST[cat]/struct") && !unlink("$dir/pages/$_POST[cat]/struct"))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
        
        
// Remove the directory
        
if(!rmdir("$dir/pages/$_POST[cat]"))
        {
            
header('Location: /index.php?section=admin&page=failure');
            die();
        }
... 
The struct file is just a file which is used by other parts of the site to maintain the directory structure. (The entire site is just a pre-alpha type thing for learning PHP and eventually some of the code will go into our team's site. The main thing is a user can login and edit content pages over the web.) The struct file does get deleted successfully; I see it disappear in my little Windows Explorer window. $dir contains a path which is brings the path back to the root of the site before going deeper in. In this case, it equals "./..". (The reason for the ./ at the beginning is how I generated it. I was too lazy to remove that part of it, as it shouldn't make a difference. Does it?)

I'm using pretty much the ship configuration which is in the php.ini-dist.recommended (or whatever that file was called) file.

Ideas? Was I unclear?
__________________


Last edited by Ryan M. : 05-12-2004 at 15:06.