如何使用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