Leonardo
Leonardo

Reputation: 2363

How to copy an external image to local?

I want to retrive an http external image an copy it to a folder on my server (eg. /images/example.jpg)

Is there a way to do this with symfony 2.0 or with basic PHP 5 functions?

Upvotes: 0

Views: 857

Answers (1)

flykobe
flykobe

Reputation: 135

you can do it like this:

file_put_contents('tmp.jpg', file_get_contents('http://static.adzerk.net/Advertisers/3603.jpg'));

But, be careful, if it's a web page, it maybe very slow, depending on the speed of image page.

Upvotes: 3

Related Questions