Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to move files through windows shares by php pages.

In a linux context I will use samba client to mount the share to a local path, however i can not understand how to do this in a windows webserver.

The webserver is running as "SYSTEM" user and I can not specify a valid share user.

share|improve this question

In Windows, just use the following synthax in the php command "copy":

copy("\\server_source\path", "\\server_dest\path");

You need permissions to copy files (check the configuration of the webserver you're using, the user who's running the webserver must be included with r/w permissions).

If you haven't permissions, run a

system("net use drive1: \\server_source\path password /USER:user@domain.tld");
system("net use drive2: \\server_dest\path password /USER:user@domain.tld");


copy("drive1:\path", "drive2:\path");

You must know which drive letter from Z: down to E: are available on your server.

share|improve this answer
Is "net use" global for all account and also for webserver? – Tobia Jan 18 '13 at 10:01
This don't work, I can access drive1:\\ and driver2:\\ but copy fails. – Tobia Jan 18 '13 at 10:06
Which version of Windows you're using? – AndrewQ Jan 18 '13 at 10:10
Windows Server2012 – Tobia Jan 18 '13 at 10:25
Can you post the exact error? – AndrewQ Jan 18 '13 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.