1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Cannot delete, cannot chage permission...

Discussion in 'PHP' started by mahmood, Jan 12, 2008.

  1. #1
    I have created some directories using mkdir($path,0755)

    Now when I want to delete the directory I get permission error and when I want to change the permission using chmod, I get the same error.

    I am also not able to change permission using FTP program or dreamweaver.

    What do I do?
     
    mahmood, Jan 12, 2008 IP
  2. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Hello :)

    When you create files and directorys with PHP the owner may not get to be the same as when you upload or create them with your ftp program or Dreamveaver.

    Usually when files or directorys are created with PHP the owner gets to be "nobody".

    When you log in with Dreamweaver or ftp program, you log in as the owner of the account and not as "nobody". This I believe is whats causing your problem. Unfortunately Dreamweaver and most ftp programs can't change owner on files and directorys.

    You have a few options on what to do.

    In your script, either use the chown('/path/to/file/or/dir, 'owner_here'); command to change owner or use the unlink('path/to/file/'); command to delete files and rmdir('/path/to/directory'); to remove directorys (the dir must be empty though).

    You will find some useful tips and codesnippets following above links to the manual.

    You could set the owner at the same time as you create files and directorys to avoid this annoyment :)

    If you dont want to go trough this trouble, I recommend you to check out winscp. It's a free ftp/ssh program.

    With winscp you can easily execute ssh commands that does these tasks in the most easy and efficient way and a lot faster. Like changing owner or removing dirs and files all at once using ssh commands.

    Ok, just my $0,02. Good luck :)
     
    wing, Jan 12, 2008 IP
    mahmood likes this.
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #3
    Just login to cpanel and using filemanager you can create folder with required permissions

    Regarding the folder you have created if you want it to be deleted ask the hosting provider they will delete it for you

    Regards

    Alex
     
    kmap, Jan 12, 2008 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    if you have root access or a super user, you can change the owner of the file like so.

    chown user:user file.php
    chown -R user:user folder
     
    Kaizoku, Jan 12, 2008 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I've never used Dreamweaver, but many FTP clients allow sending raw commands to the server, in which case you can do something like "SITE chmod 0775 dirname".

    It's rare that the web server process would have the rights to change a file's owner. To do this it would have to be running as root.

    In general, if you have write permission on a directory, then you can remove files or directories contained therein, even if you don't actually have permissions on those files or directories. So make sure that the user who is trying to delete the files is allowed to write to the parent directory and the problem goes away.
     
    SmallPotatoes, Jan 12, 2008 IP