Fopen 到远程 php 脚本
我必须下载一个由 php 脚本创建的文件。
我尝试了这个:
fopen('www.example.com/download.php?key=value', 'rb');
但我仍然收到“无法打开流”错误。
我怎样才能做到这一点?如果我浏览到该网址,我会毫无问题地获取文件...
编辑:抱歉,我忘记了一段字符串:)
i have to download a file created from a php script.
i tried this:
fopen('www.example.com/download.php?key=value', 'rb');
but i stille get a "failed to open stream" error.
how can i do that? If I browse to the url i get the file without problems...
EDIT: sorry, i forgot a piece of the string :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现您的请求存在多个问题:
您需要指定打开模式。在您的情况下,只有'r'
适用,因为您只想读取。phpinfo()
并查看allow_url_fopen
是否设置为On
。fopen
,请不要忘记fclose
。示例:
您还应该阅读手册中有关 fopen 的内容。
I see multiple issues with you request:
You need to specify the open mode. In your case only'r'
applies because you only want to read.phpinfo()
and look ifallow_url_fopen
is set toOn
.fclose
if you decide to usefopen
.Example:
You should also read about fopen in the Manual.
看起来您需要首先阅读
fopen
的用法,这里是一个示例用法:r = read,这可能会导致您的失败。
It looks like you need to read the usage for
fopen
first, here is an example usage:r = read, that might be causing your failure.