问题
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