问题描述
我的问题是我无法在远程服务器上包含文件.
My problem is that I can't include a file on a remote server.
<?php
echo "Including\n";
require_once("http://xx.xxx.xxx.xx:8080/path/to/myfile.inc");
echo "Done..\n";
?>
该脚本在require_once函数处失败.我正在使用以下脚本运行脚本:php -d allow_url_include =在script.php上但要确保我已在php.ini中将allow_url_include和allow_url_fopen设置为On
The script fails at the require_once function.I'm running the script with: php -d allow_url_include=On script.phpbut to make sure I have set allow_url_include and allow_url_fopen to On in php.ini
如果我复制 http://xx.xxx.xxx.xx :8080/path/to/myfile.inc 到我提供文件的浏览器.我还尝试过包含其他远程文件(在标准端口80上),但仍然没有运气
If I copy http://xx.xxx.xxx.xx:8080/path/to/myfile.inc to the browser I'm served the file.I have also tried to include other remote files (on standard port 80), but still no luck
我真正感到困惑的是,一切都可以在我办公室的本地计算机(mac,ubuntu)上运行,而不能从我们的服务器上运行.我已经在2个不同的服务器(虚拟服务器和专用服务器)上对其进行了测试.我可以使用fopen()获取文件.
Where I get really confused is that everything works from my local computers at my office (mac, ubuntu), but not from our servers. I have tested it on 2 different servers, a virtual and a dedicated.I can get the file with fopen().
推荐答案
这可以通过在php.ini上将allow_url_include
设置为on
来完成.
This can be done by setting allow_url_include
to on
on php.ini.
但是,正如评论中所述,这会打开
But, as mentioned in comments, this opens a
应用程序上的安全漏洞.
security hole on your application.
这篇关于无法包含远程服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!