Read file on a network drive

You’re not able to do this using a drive letter, as network mapped drives are for a single user only and so can’t be used by services (even if you were to mount it for that user).

What you can do instead is use the UNC path directly, for example:

fopen('\\\\server\\share\\text.txt', 'r');

Note, however, that there are a few issues with PHP’s filesystem access for UNC paths. One example is a bug I filed for imagettftext, but there are also issues with file_exists and is_writeable. I haven’t reported the latter because as you can see from my long-outstanding bug with imagettftext, what’s the point.

Leave a Comment