Permission problems with unlink()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benjamin

    Permission problems with unlink()

    Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
    to unlink I get this: "Warning: unlink(file.txt ) [function.unlink]:
    Permission denied..." What and how do I change this so it works?
    Thanks

  • terence.parker@gmail.com

    #2
    Re: Permission problems with unlink()

    This could be a permission issue. To unlink a file your webserver must
    have the permissions to remove it. Most likely your apache is running
    as user 'apache', so the file you are removing must either be owned by
    user/group apache, or have permissions to be removed by any user (666 /
    777).

    Terence



    Benjamin wrote:
    Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
    to unlink I get this: "Warning: unlink(file.txt ) [function.unlink]:
    Permission denied..." What and how do I change this so it works?
    Thanks

    Comment

    • Benjamin

      #3
      Re: Permission problems with unlink()

      I'm sorry I forgot to mention that I'm running windows.

      terence.parker@ gmail.com wrote:
      This could be a permission issue. To unlink a file your webserver must
      have the permissions to remove it. Most likely your apache is running
      as user 'apache', so the file you are removing must either be owned by
      user/group apache, or have permissions to be removed by any user (666 /
      777).
      >
      Terence
      >
      >
      >
      Benjamin wrote:
      Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
      to unlink I get this: "Warning: unlink(file.txt ) [function.unlink]:
      Permission denied..." What and how do I change this so it works?
      Thanks

      Comment

      • Alvaro G. Vicario

        #4
        Re: Permission problems with unlink()

        *** Benjamin escribió/wrote (19 Aug 2006 11:04:15 -0700):
        I'm sorry I forgot to mention that I'm running windows.
        Then right click on the icon in Windows explorer, select "Properties ", find
        the "Security" tab and set permissions accordingly.

        >This could be a permission issue. To unlink a file your webserver must
        >have the permissions to remove it. Most likely your apache is running
        >as user 'apache', so the file you are removing must either be owned by
        >user/group apache, or have permissions to be removed by any user (666 /
        >777).

        --
        -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
        ++ Mi sitio sobre programación web: http://bits.demogracia.com
        +- Mi web de humor con rayos UVA: http://www.demogracia.com
        --

        Comment

        • Benjamin

          #5
          Re: Permission problems with unlink()

          I figured it out. It was stupid really. I had opened the file with
          fopen() without running fclose() before trying to unlink() it. Thanks
          for your help though.
          Alvaro G. Vicario wrote:
          *** Benjamin escribió/wrote (19 Aug 2006 11:04:15 -0700):
          I'm sorry I forgot to mention that I'm running windows.
          >
          Then right click on the icon in Windows explorer, select "Properties ", find
          the "Security" tab and set permissions accordingly.
          >
          >
          This could be a permission issue. To unlink a file your webserver must
          have the permissions to remove it. Most likely your apache is running
          as user 'apache', so the file you are removing must either be owned by
          user/group apache, or have permissions to be removed by any user (666 /
          777).
          >
          >
          --
          -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
          ++ Mi sitio sobre programación web: http://bits.demogracia.com
          +- Mi web de humor con rayos UVA: http://www.demogracia.com
          --

          Comment

          • Carl Vondrick

            #6
            Re: Permission problems with unlink()

            Benjamin wrote:
            Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
            to unlink I get this: "Warning: unlink(file.txt ) [function.unlink]:
            Permission denied..." What and how do I change this so it works?
            Thanks
            Does this happen on PHP 5.1? It may be a PHP5.2 bug, in which case you
            should report it.

            We need to see some code first, but my guess is that you do not have
            permission to delete that file. What is the file CHMOD'd to? Can you
            delete it via the command line?

            Also, if you unlink something at script shut down (__destruct() for
            example), you will run into problems with permissions, because the
            engine is in the processing of shutting down and many streams are killed
            -- such as MySQL, and likely the filesystem.

            Carl


            --
            Carl Vondrick
            www.YoungCoders.com -- Forum for the younger, next generation programmers.

            Comment

            • Benjamin

              #7
              Re: Permission problems with unlink()

              It was totally my fault.
              I had created the file with fopen and failed to call fclose before
              trying to delete it. I suppose that fopen had use of the file so I
              couldn't alter it.
              Carl Vondrick wrote:
              Benjamin wrote:
              Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try
              to unlink I get this: "Warning: unlink(file.txt ) [function.unlink]:
              Permission denied..." What and how do I change this so it works?
              Thanks
              >
              Does this happen on PHP 5.1? It may be a PHP5.2 bug, in which case you
              should report it.
              >
              We need to see some code first, but my guess is that you do not have
              permission to delete that file. What is the file CHMOD'd to? Can you
              delete it via the command line?
              >
              Also, if you unlink something at script shut down (__destruct() for
              example), you will run into problems with permissions, because the
              engine is in the processing of shutting down and many streams are killed
              -- such as MySQL, and likely the filesystem.
              >
              Carl
              >
              >
              --
              Carl Vondrick
              www.YoungCoders.com -- Forum for the younger, next generation programmers.

              Comment

              Working...