无法包含远程服务器上的文件 [英] Can't include file on remote server

查看:103
本文介绍了无法包含远程服务器上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我无法在远程服务器上包含文件.

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.php but 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.

这篇关于无法包含远程服务器上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆