Windows network drive from PHP running on a linux

2019-08-01 10:08发布

问题:

I have to check something if it works.

We have limited access to a Debian server via ssh. We have a PHP intranet solution running on this server, so we can run PHP scripts. We got the following scenario:

A windows network drive given: \\IP\folder$

We have to read this windows network drive from PHP under linux. I never did such thing.

We have no any rights to mount anything on the server. This drive may or may not accessable from the linux machine, I don't know. (I guess it's accessable, due to the scenario).

We didn't receive any user&pass for the drive, so I guess we don't need it.

The question is: is it possible to do this in this situation if everything was set up correctly on the customer side? If yes, how?

We can ask more information and configuration changes if we need it, but I'm wondering if we can do this now, because it's interesting.

Thanks in advance,

negra

回答1:

You can use smbclient to access the share. You could consider it as a sort of 'ftp' client, but for accessing Windows shares instead. It can work without need for mounting, and you should be able to talk to it directly from PHP using popen() for bi-directional communication of commands/results.

However, this depends on the share actually being remotely accessible, and you having access rights to it (via a windows account or the share having 'everyone/read' permissions). If windows networking is firewalled and/or you don't have access permissions, then there's nothing you can do to access the files directly.