Answer the question
In order to leave comments, you need to log in
How to open a remote directory in PHP?
At the enterprise there is a network, on computers of users the virtual disk is connected. There is a server (Ubuntu + Apache + PHP) from which one of the sections of the corporate portal works. From this server there is a need to access a folder on a shared network drive, get a directory of files and process them.
The essence of the issue, the folder is visible from the browser ( file://192.168.100.90/fs/inv/ - the directory opens), visible from Windows ( "Win" + "R" => \\192.168.100.90\fs\inv => opens folder ), but it fails from PHP:
$dir = "\\\\192.168.100.90\\fs\\inv";
$catalog = opendir($dir);
PHP Warning – yii\base\ErrorException
opendir(\\192.168.100.90\fs\inv): failed to open dir: No such file or directory
$dir = "file://192.168.100.90/fs/inv/";
$catalog = opendir($dir);
PHP Warning – yii\base\ErrorException
opendir(): remote host file access not supported, file://192.168.100.90/fs/inv/
Answer the question
In order to leave comments, you need to log in
You can mount it, you can use some kind of SMB client , but it would be better to think hard about how you got into this situation, and whether it is worth tweaking the architecture of the entire system a little.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question