SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict peterb's Avatar
    Join Date
    Jun 2003
    Location
    Athens, Greece
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    deleting files using unlink question

    Hello all,

    I have a record in the db and a picture file name recorded with that record.
    I am writing a deletion routine which checks that file name and is supposed to delete it using unlink.

    Although it reports the correct directory and file name, I received the following:
    Warning: unlink(/home/pab/html/pics/test.jpg) [function.unlink]: Permission denied

    I checked my permissions and the file is set at my user name and 666.

    Does anyone know why this won't work or maybe another way to delete the file?

    Thanks,
    Peter

  2. #2
    SitePoint Enthusiast craigv's Avatar
    Join Date
    Dec 2003
    Location
    minneapolis, mn
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may need higher permissions...like 755, which is full for owner, read and execute for others. Have you experimented with that at all? A permissions error is just that, a permissions error. I'm sure with some experimentation you will get it. Just don't leave a folder with 7's in a public directory.

    I could be wrong, but that's a rule that I've learned to follow. I usually do all of my 777 stuff in a folder outside of my website so I can do writing, deleting, moving, etc. and then just link to these files from within my public docs.

  3. #3
    SitePoint Addict peterb's Avatar
    Join Date
    Jun 2003
    Location
    Athens, Greece
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi craigv,

    as I tend to have gif or jpg's in a directory in a sub-directory of public_html directory that's a little tough.
    I would hate to have to re-arrange picture directories and html as well.
    Is there a way to chmod using php to do that?

    A Happy New Year to all,
    Peter

  4. #4
    SitePoint Enthusiast craigv's Avatar
    Join Date
    Dec 2003
    Location
    minneapolis, mn
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've explored that myself and never did have success with runtime php chmod on a public directory unless the permissions were set higher than I was comfortable with.

    I know it's a hassle to think about restructuring your site, but it will provide a lot in the name of security.

    I'd love for someone else to chime in on this.

  5. #5
    SitePoint Addict peterb's Avatar
    Join Date
    Jun 2003
    Location
    Athens, Greece
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Yes I would like to see comments from others regarding this too.
    I tried changing the permissions on the test file on my linux server to 777 but it still didn't work.
    I guess that I will have to search around to see if I can find any additional info on this subject.

    Thanks,

    Peter

  6. #6
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I know it's an old topic and peterb must have found the solution already or doesn't need it anymore. For anyone else who came on this thread by search engine (like me):

    You have to make sure that you have writing permission on the folder the file is in. It makes no difference whether the file-permissions are set to 777, but make sure you set the folder's permissions to 777. More specific; it's important to set the groups permissions on the folder to 7 so _7_
    Last edited by Plaus; Dec 9, 2007 at 10:00.

  7. #7
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,098
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have run into ht_docs (root) to be 775 and then all directories within to be 777 as well as files if the files that need changing were uploaded via ftp.

    files uploaded with ftp are owned by you.

    I like to use php to create all files and directories on the server since they are all owned by apache and do not need any permissions to be changed.
    What I lack in acuracy I make up for in misteaks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •