How to download php generated zip/rar file with file

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


Don't you mean that it return false ?

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


Resources :

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

  • different host and mimetype returns empty so i can't hadle those packages.

  • just installed http and got more information about link and yes it is redirected so is file_get_contents only way to go or does curl support redirection?
  • Got it

    Found script from http://w-shadow.com/blog/2008/07/05/how-to-get-redirect-url-in-php/ which got me through with redirect link issue so now i got good script to fetch data.

    Thank you all

    链接地址: http://www.djcxy.com/p/65592.html

    上一篇: 使用文件时出错

    下一篇: 如何用文件下载php生成的zip / rar文件