As it seems one possible solution while trying to download images with PHP is to write a “client” to do so. Will it be with cURL, Zend Framework or some other tool – it doesn’t matter.
However one of the most used approaches is simply with file_get_contents and file_put_contents. I’m not sure whether I wrote already about this or not, but this solution simply looks something like this.
file_put_contents('/path/to/file', file_get_contents('http://www.example.com/source.image'); |
In fact a client will give you more control over the process, to handle errors, etc. So maybe this is a better solution.
Hey I just came here randomly but reading through all of your PHP posts – very impressive and worth reading all of them.
You don’t event need 2 function calls file_get_contents() and file_put_contents – just use copy()!
this requires fopen allowed as file_get_contents() does.
Thank you very much. It worked for me. Its very quick n short way.