Search code examples
phpfile-exists

access data from network / with php


if i try to access data from my computer it works

$test = "\\\\Pcname\folder\blabla.txt";
or
$test = "D:\\folder\blabla.txt;
if (!file_exists($test)) {
    die("Could not find file.");
}

but i want to access data from local network(shared folder) but i got error and i have no clue how to make it works

i try this code

$test= "http://10.0.0.107/folder/blabla.txt";
or using computer name
$test= "http://Another-Pc/folder/blabla.txt";

I also make sure if permision folder are full control for everyone and even make a group


Solution

  • If you are trying to access it locally, that would be definitely a burden and may not be possible. First, because PHP will not have these settings (security purposes) and second depending on the OS, OS may or may not allow this.

    As NullUserException mentioned, you should either install Apache or IIS to the PC to serve the HTTP and open the port 80 to the Network then you can check the file with the http URL.

    I hope this helps.