Ogugua Belonwu
Ogugua Belonwu

Reputation: 2141

Saving an Image

I have a picture url like this http://www.address.com/image.jpg

I want do dynamically save this image on my server

How can i achieve this using php

Thanks

Upvotes: 0

Views: 237

Answers (1)

NullUserException
NullUserException

Reputation: 85478

You can get it using file_get_contents() and saving it using file_put_contents(). Something like:

$image = file_get_contents('http://www.address.com/image.jpg');
file_put_contents('image.jpg', $image);

You also might want look into cURL to fetch the image; it should perform better than file_get_contents() (unless you compile curl with --with-curlwrappers)

Upvotes: 2

Related Questions