php file_get_contents() 无法打开流:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20349562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
file_get_contents() failed to open stream: No such file or directory
提问by Yunus Aslam
I am writing some php script to update the code on my sites. In order to do that I have written the following lines which checks for the update version and bring the name from where I use to distribute my updates ans then creates the link of that name. I have done something like this.
我正在编写一些 php 脚本来更新我网站上的代码。为了做到这一点,我编写了以下几行代码,用于检查更新版本并从我用来分发更新的位置获取名称,然后创建该名称的链接。我做过这样的事情。
$filename = "http://www.hf-live.com/codeupdate/Get_Files_Name.php";
$contents = file_get_contents($filename);
echo $contents;
I am getting this error
我收到此错误
failed to open stream: No such file or directory.
无法打开流:没有这样的文件或目录。
Even though the file is present still I am getting the same error. I have turned on my allow_url_fopento on. The above code is working from my local host but not from the server. I have to update a major bug fix and I am stuck.. Please someone help me soon..
即使文件存在,我仍然遇到相同的错误。我已经打开了我的allow_url_fopento on。上面的代码在我的本地主机上运行,但不在服务器上运行。我必须更新一个主要的错误修复程序,但我被卡住了.. 请有人尽快帮助我..
回答by Kalpit
remove extra .php from url
从 url 中删除额外的 .php
$filename = "http://www.hf-live.com/codeupdate/Get_Files_Name.php";
You will get error if you are doing this way...
如果你这样做,你会得到错误......
$filename = "marynyhof.com/Info.php"; // will give you error, which exactly you are getting
use full url like this
像这样使用完整的网址
$filename = "http://www.marynyhof.com/Info.php"; //will work

