Skip to content
Advertisement

Copy network file from a Linux host to my Linux server using PHP

I am trying to retrieve a network file from an OpenSUSE 13.1 Host to my OpenSUSE 13.2 Webserver, but I don’t seem to have any success.

First I check if target directory is a directory:

$path = "\\192.168.xxx.xxx\public";
if(is_dir($path)){ // returns FALSE every time.
  return true;
}

In this case the function is_dir() returns FALSE, although the folder exists and has 777 permisions, the IP is correct, and the computer is turned ON. I have tried all the combinations of formatting the network path, including $path = "smb://192.168.xxx.xxx/public"; witch returns an error

Unable to find the wrapper “smb” – did you forget to enable it when you configured PHP?

Could someone tell me what I am missing?

Would it work the same through a OpenVPN with my Centos 6 webserver and an Ubuntu 14 host?

Advertisement

Answer

PHP has no built-in Samba support on the Linux platform. You will need to mount the remote share (requires superuser-equivalent access) and access its contents like a local filesystem.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement