I have a script which generates an image. I have used it like this so far:
<img src='/img/avatar/identicon.php?size=35&hash=64d134jf23tgr7k' height='40' width='40'>
Now I'm trying to store it as a image in this path:
/img/avatar/$id.jpg
And then use it like this:
<img src='/img/avatar/$id.jpg' height='40' width='40'>
How can I store that image as a real image in a folder?
Note: I have id
as a dynamic variable, and I want to use it as the name of image.
You'll need to save the image first, here's one way to do it:
$id = "someID.jpg";
file_put_contents("img/avatar/".$id, file_get_contents("http://somesite/img/avatar/identicon.php?size=35&hash=64d134jf23tgr7k"));
then use it like this:
<img src='/img/avatar/<?=$id?>' height='40' width='40'>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.