Home >Backend Development >PHP Tutorial >How to Access Network Drive Files from PHP Service Running on Windows Server?
Accessing Network Drive File from PHP Service
Running Xampp on Windows Server with Apache as a service under a local account can create challenges when accessing files located on a network drive. Attempting to open a file on the network drive using the drive letter syntax (e.g., 'X:text.txt') can result in an error.
Solution:
Drive letters are mapped to network drives for individual users and are not available to services. To address this issue, use the UNC path directly when accessing the file, as shown below:
<code class="php">fopen('\\server\share\text.txt', 'r');</code>
Limitations:
While using UNC paths solves the issue for most cases, there are certain limitations to PHP's filesystem access for UNC paths:
The above is the detailed content of How to Access Network Drive Files from PHP Service Running on Windows Server?. For more information, please follow other related articles on the PHP Chinese website!