【问题标题】:Displaying image from different disk显示来自不同磁盘的图像
【发布时间】:2016-02-07 16:46:52
【问题描述】:

嗨,我想显示来自不同磁盘的图像。 这是我的代码。 有可能吗?

      $a = "D:/img/1.jpg";
      <img src="<?php echo $a; ?>"  alt="...">

我在我的本地主机上使用它。这不适用于网络。

我在这里添加截图。 当我来到 img 上方时,它会显示链接。但不显示 img。我用灯箱。 但没有灯箱就不会再显示了。

example

【问题讨论】:

  • D: 将无法通过网络访问。
  • 我会在本地使用它
  • @ÖzgürŞana 是的,你最好把它改成你当地的。所以图片也可以通过网站访问。
  • @chris85 我查过了,但没明白。

标签: php html


【解决方案1】:

我想将此类 URL 与协议一起使用:$a = 'file:///D:/img/1.jpg';

【讨论】:

【解决方案2】:

您提供/附加的示例仅在您将 html 文件直接加载到浏览器时才可用。如果您通过 localhost 加载它是不可能的。在你的情况下,你将不得不做这样的事情:

<?php
$image = file_get_contents('D:/img/1.jpg');
$image_codes = base64_encode($image);
?>
<image src="data:image/jpg;charset=utf-8;base64,<?php echo $image_codes; ?>" />

参考:How to retrieve and show images from another drive using src attribute in <img> tag?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 2021-08-25
    • 2017-08-23
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多