Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My problem is that I can't include a file on a remote server.

<?php
  echo "Including
";
  require_once("http://xx.xxx.xxx.xx:8080/path/to/myfile.inc");
  echo "Done..
";
?>

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

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

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().

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
435 views
Welcome To Ask or Share your Answers For Others

1 Answer

This can be done by setting allow_url_include to on on php.ini.

But, as mentioned in comments, this opens a

huge

security hole on your application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...