开发者

Saving an Image

开发者 https://www.devze.com 2023-01-18 00:51 出处:网络
I have a picture url like this http://www.address.com/image.jpg I want do dyn开发者_如何学编程amically save this image on my server

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

I want do dyn开发者_如何学编程amically save this image on my server

How can i achieve this using php

Thanks


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消