How to download php generated zip/rar file with file_get_contents

时间秒杀一切 提交于 2019-12-11 17:31:06

问题


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


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/3729583/how-to-download-php-generated-zip-rar-file-with-file-get-contents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!