tags:

views:

626

answers:

3

(Assuming the network folders/permissions are correctly set up and working in Windows, and a 'default' PHP setup...)

Is it possible to use UNC network paths [like \\ServerName\Folder\file.txt] in PHP's functions like file_get_contents(), fopen(), etc?

And/or, what special cases allow/disallow this?

+1  A: 

UNC paths should "WORK" if permissions are set properly. And the network folders are allowed to be accessed by apache user, then there won't be any problem.

In these scenarios open_basedir creates problems, just keep an eye on that

Ish Kumar
The script is not executed by the ftp server ;-) YOu mean the web/http server.
VolkerK
I mean apache user, my mistake VolkerK
Ish Kumar
A: 

PHP absolutely permits UNC paths. You may have issues regarding which user is actually executing the code. If it is Apache running as a service then the user will be whatever user is listed in the entry for the windows service. if it is IIS then the user is typically IUSR_machineName. If it is as a console then it is the currently executing user.

Ben Reisner
In reference to Alex's statement about mapped network drives I do not recomment this. Mapped network drives are not available to PHP applications that are running inside of a web server running as a service. One application I have that requires use of mapped network drives is forced to run the web server as a console application (apache is in the startup and the server must always be logged in)
Ben Reisner
A: 

no, unc path not work with command like @exec for exemple ! (if you have a php script inside an unc path that do @exec, it's will failed, even if the @exec point to an executable in your c:\ directory)

Loki