File write permission denied on Windows host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • unauthorized
    New Member
    • May 2009
    • 81

    File write permission denied on Windows host

    I'm running a PHP 5.1 on an Apache 2.2 server under Windows XP which I use to develop my web apps.
    Currently, I am trying to add "upload" functionality to my project, but for some reason, when the move_uploaded_f ile() function is called on it, the following error is generated:
    Warning: move_uploaded_f ile(D:/web_services/httproot/nbprj/img/u) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Web_Services \php_include\ad min\manimgs.php on line 120

    Warning: move_uploaded_f ile() [function.move-uploaded-file]: Unable to move 'D:\Web_Service s\http_inc\phpC 4.tmp' to 'D:/web_services/httproot/nbprj/img/u' in D:\Web_Services \php_include\ad min\manimgs.php on line 120
    Now this error may appear to be simple write permission issue, but the account that is running the service has full r/w permissions to the directory that is supposed to host the uploaded file:
    Code:
    D:\Web_Services\httproot\nbprj\img\u>echo %USERNAME%
    Web Service
    
    D:\Web_Services\httproot\nbprj\img\u>echo "some text" >> file.txt
    
    D:\Web_Services\httproot\nbprj\img\u>type file.txt
    "some text"
    
    D:\Web_Services\httproot\nbprj\img\u>del file.txt
    
    D:\Web_Services\httproot\nbprj\img\u>
    See the attachment for a screenshot on my permission settings.

    I'm certain that "Web Service" is the account that is running the httpd server.
    Any ideas what is causing me a headache?
    Attached Files
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Try chmod()ing the directory prior to your upload.

    Comment

    • unauthorized
      New Member
      • May 2009
      • 81

      #3
      Originally posted by Markus
      Try chmod()ing the directory prior to your upload.
      I did a chmod($path, 0777) but the result is still the same.

      Comment

      • unauthorized
        New Member
        • May 2009
        • 81

        #4
        Resolved.
        My code was not adding the file name to the move_uploaded_f ile() function and thus the script was failing to overwrite the existing directory with the uploaded file.
        Very careless of me, I know.

        Comment

        Working...