V
V
Vasily2018-02-27 06:59:05
PHP
Vasily, 2018-02-27 06:59:05

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/

I read that it is easier to mount a remote folder in Ubuntu and read from it locally, but according to the words, this is not very reliable.
Are there any other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2018-02-27
@parazitl2

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 question

Ask a Question

731 491 924 answers to any question