简体   繁体   English

从远程PC获取文件

[英]Get file from distant PC

I have a PC connected to a Raspberry via an Ethernet network. 我有一台通过以太网连接到Raspberry的PC。 In Raspberry there is the file Stb.php in directory /var/www/ the IP of Raspberry is 192.168.1.15. 在Raspberry中,目录/ var / www /中有文件Stb.php,Raspberry的IP是192.168.1.15。 I like to use a function in file Stb.php named sendScreenCommand from my server which installed in my PC. 我喜欢使用PC上安装的服务器上名为sendScreenCommand文件Stb.php中的函数。 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. 您可以在php.ini配置文件中启用allow_url_include

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. 因此,您的php文件在Raspberry上进行了解析/执行,您得到的所有内容都是结果,因此没有要执行的功能。

Unless Stb.php outputs php code of course, but that seems very unlikely from what I understand from the question... 除非Stb.php当然输出php代码,但是根据我从问题中了解的信息来看,这似乎不太可能...

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: 如果这是在本地网络上,则可以将Raspberry的文件系统安装在您的PC上,这样就可以使用它,例如:

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

(assuming something like linux or OSX, on Windows it would be a bit different) (假设类似linux或OSX,在Windows上会有所不同)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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