Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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");

then:

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

 
discard

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.