Why is PHP unable to copy the file to a shared folder on the local network?

I need to copy a file from one computer to another computer that is connected to the local network. I have the IP address of these two machines. I used this code for this,

$file = 'file.text';// inside htdocs folder
$newfile = '\\\\192.168.1.15\\htdocsfolder\\';
if ( copy($file, $newfile) ) {
    echo "Copy success!";
}else{
    echo "Copy failed.";
}

but the copy failed. How to debug, why the file is not copied to another htdocs folder of the computer? Do I need to change the sharing on both computers?

Please, help. Thanks

+3
source share
2 answers

You seem to be on a Windows machine. Here are a few things to keep in mind and verify (which are a variation of the same theme):

  • / , , ( ):

    C:\> path-to-PHP .php

  • , , - :

    • Webserver \\192.168.1.15\htdocsfolder htdocs folder.
    • , -. //, , .
    • Active Directory,
    • OTOH , , ( ) .
    • , ( ).
    • MS Windows, , " " → " " → " " Microsoft.

, , Google SO - .

0

, , PHP , . Linux, . , .

0

All Articles