Jump to content

Recommended Posts

I'm using a PHP script from the command line to copy files from a mapped drive on a remote computer to a folder on the local computer where PHP is running. I get an "Access is denied (code: 5)" error.

When PHP runs from the command line, is it using the same user account it runs with when it runs in the browser?

How can I tell if the access is denied on the remote side or the local side?

What account would need to have read/write permissions set?

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/288262-cant-copy-files/
Share on other sites

PHP will be run as whatever user started it. If you ran it yourself, manually from the command line, then it will run as your user. When run by a web server (eg, when accessed through a browser) then it will run as whatever user the web server is running as: Apache is probably running as LOCAL_SYSTEM (which does not have networking privileges, so I suspect this is your problem) while IIS will run as a specific user account dedicated it (like "IUSR" or "IUSR_machine").

 

The best solution that I know for Apache on Windows is to create a brand-new user account just for it - so much like how IIS runs. The account will have networking privileges by default and your script should be fine. From there you can even manage file and directory permissions.

Link to comment
https://forums.phpfreaks.com/topic/288262-cant-copy-files/#findComment-1478288
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.