unlink - permission denied

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitinpatel1117
    New Member
    • Jun 2007
    • 111

    #1

    unlink - permission denied

    Hi

    I am trying to delete a csv file using the unlink() function, but i keep getting a permission denied warning

    Warning: unlink(UsedNOS2 00704191.CSV): Permission denied in E:\webroot\dev\ file_test\index .php on line 416


    My script basically reads email attachments and downloads the attachment file into the current directory of the running script. The data in the attachements is then read and stored into MySQL. Once i've finished reading this file, i need to delete it.

    When i unlink excel files (.xls) everything is OK and this produces no errors/warning, however, when i try to unlink the (.csv) files. i get a permission denied warning.


    The same script which creates the file (from email attachment) is doing the deleting (unlink() funtion), once the file has been read. So, therefore in terms of owning a directory or file and having access writes to that directory should not be a problem. as its the same script which created the file in the first place.

    The open connection to the file is closed beofre i try to delete it, but this is not the issue.

    Why am i able to unlink the excel files and not the csv files, its the same script that creates both file type, reads both file type and eventually (should) delete both file types.

    Any help on this mater would be appretiated, as i'm tried everything without much success.

    Thanks in advance
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    #2
    what is your permission set to on the file? i think 750 is the right setting, or u can always try 770

    Comment

    • nitinpatel1117
      New Member
      • Jun 2007
      • 111

      #3
      I am using PHP in a windows environment, I never knew that the file permission system applied in this environment.

      But i have checked the file permissions and it's currently set to: 666 for the CSV file and excel file. So both files have the same file permissions. therefore, if the excel file can be deleted then so should the csv file.

      i can't use chmod to change the permissions as its a unix command,

      I am using
      fopen($filename ,"w");
      to create the csv file in the first place. Is there a parameter that i have missed out here or another step that follows this.
      Last edited by nitinpatel1117; Jun 6 '07, 08:44 AM. Reason: not detailed enough

      Comment

      • nitinpatel1117
        New Member
        • Jun 2007
        • 111

        #4
        Ok, i've fixed the problem.

        basically the connection to the file (after reading from it) wasn't properly closed.

        therefore, the file was still open for reading.
        Last edited by nitinpatel1117; Jun 6 '07, 12:03 PM. Reason: spelling mistake

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          Originally posted by nitinpatel1117
          Ok, i've fixed the problem.

          basically the connection to the file (after reading from it) wasn't properly closed.

          therefore, the file was still open for reading.
          I'm glad you found the solution for your problem, and grateful that you posted it back here for the rest of the community to learn from!

          Comment

          Working...