简体   繁体   中英

Displaying image from different disk

Hi i want to show images from different disk. Here is my code. is it possible to do that ?

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

Im using this on my localhost.This is not for the web.

i add screenshot here. when i come above the img it shows the link. but not show img. and i use lightbox. but without lightbox its not show again.

example

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

The sample you provided/attached is only doable if you load the html file directly to your browser. It is not possible if you load it via localhost. In your case, you will have to do something like this:

<?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; ?>" />

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM