保存图像

发布于 2024-09-24 20:12:25 字数 177 浏览 0 评论 0原文

我有一个像这样的图片网址 http://www.address.com/image.jpg

我想要动态地将此图像保存在我的服务器上

我如何使用 php 实现此目的

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴梦一场 2024-10-01 20:12:25

您可以使用 file_get_contents() 并使用 file_put_contents()< 保存它/a>.例如:

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

您可能还需要查看 cURL 来获取图像;它应该比 file_get_contents() 表现更好(除非您使用 --with-curlwrappers 编译curl)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文