从网址到主页的PHP显示图像 [英] Php display image from url into homepage

查看:116
本文介绍了从网址到主页的PHP显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在没有人回答这个问题之后 Php Rss feed使用img in CDATA - >内容:编码我尝试做其他事情来解决这个问题......

after no one answered at this question Php Rss feed use img in CDATA -> content:encoded i try to do something else solving this problem...

如何将来自给定网址的图片直接加载到我的主页?

how can i load an image from a given url directly into my homepage?

<?php
     $url = "...";
     $image = file_get_contents("$url");
     echo $image;
?>

*我不想将图像保存在任何地方......只需从网址加载图片并在我自己的主页上显示。

*i don't want to save the image anywhere... just load the image from the url and show it in my own homepage.

推荐答案

试试这个代码,在我的机器上正常工作。

Try this code,work fine on my machine.

<?php

$image = 'http://www.google.com/doodle4google/images/d4g_logo_global.jpg';
$imageData = base64_encode(file_get_contents($image));
echo '<img src="data:image/jpeg;base64,'.$imageData.'">';
?>

这篇关于从网址到主页的PHP显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆