如何使用file_get_contents下载php生成的zip/rar文件 [英] How to download php generated zip/rar file with file_get_contents

查看:238
本文介绍了如何使用file_get_contents下载php生成的zip/rar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对php file_get_contents();有个小问题 我尝试从网址下载压缩包,例如" http://mydomain.com?download.php? id = 1234 " 使用浏览器下载相同文件的工作原理和所有标头似乎都可以,但是通过file_get_contents文件为空...

I have small issue with php file_get_contents(); i try to download compressed packages from url like "http://mydomain.com?download.php?id=1234" downloading same file with browser works and all headers seems to be ok but through file_get_contents file is empty...

推荐答案

您不是说它返回false吗?

Don't you mean that it return false ?

无论如何,如果要下载文件,最好使用curl库和HTTP扩展名.

Anyway if you're download files, it would be better to use the curl library and the HTTP extension.

资源:

  • php.net - curl examples
  • php.net - http extension

这篇关于如何使用file_get_contents下载php生成的zip/rar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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