PHP access cifs share

network-sharePHP

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.

Best Answer

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.

Related Topic