简体   繁体   中英

Get file from distant PC

I have a PC connected to a Raspberry via an Ethernet network. In Raspberry there is the file Stb.php in directory /var/www/ the IP of Raspberry is 192.168.1.15. I like to use a function in file Stb.php named sendScreenCommand from my server which installed in my PC. Here is my code but it is not working:

include 'http://192.168.1.15/Stb.php';
$command="mkdir /flash/Resources/resources"
sendScreenCommand($command);

You can enable allow_url_include in your php.ini configuration file.

Doing this is strongly discouraged, as it can present serious security risks.

You cannot do it like that. The path you are using is a url on a web-server and according to the manual :

This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

So your php file is being parsed / executed on the Raspberry and all you get back are the results so there are not functions to execute.

Unless Stb.php outputs php code of course, but that seems very unlikely from what I understand from the question...

If this is on a local network, you could make it work if you can mount the file-system of the Raspberry on your pc so that you can use a file path like for example:

include '/mnt/Raspberry/Stb.php';

(assuming something like linux or OSX, on Windows it would be a bit different)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM