How to pass src to an <img> tag in html from a system drive?

I want to display an image on a webpage using a tag <img>.

I saved the image to my local disk.

How to do it?

The code:

<img src="D:\Images\TechnipLogo.jpg">

Image is not displayed.

+5
source share
7 answers

You must use the correct local path from your PC and the correct drive letter. Then change the backslash () to a forward slash (/) and add file: /// in front of the path, therefore:

<img src="D:\Images\TechnipLogo.jpg">

will look like this:

<img src="file:///D:/Images/TechnipLogo.jpg">

** , Chrome , , / , . , : - Chrome:

+6

, , - , .

, html , , - -.

, - Firefox IE . Chrome .

+2

-

img ,  systemlocation

img -, apache iis , img .

.

,

+1

- html

-, -.
, -.

+1

, .

, HTML D:\myhtml\home.html. "" myhtml. <img src="Images\TechnipLogo.jpg"/>.

+1

, . -. , index.html, , index.html, :

<img src="Images\TechnipLogo.jpg" />
+1

, , Apache file: file://c: c | Firefox 57.0 W7, ( php). "embedIMG.php" :

  <?php

     $file = $_GET["imgg"];
     $type = 'image/jpeg'; // or whatsoever
     header('Content-Type:'.$type);
     header('Content-Length: ' . filesize($file));
     $img = file_get_contents($file);
     echo $img;

     exit();

 ?>  

"embedIMG.php" img:

   <img src="embedIMG.php?imgg=THEPATHTOYOURIMAGE">

THEPATHTOYOURIMAGE - "D:\Images\TechnipLogo.jpg", : "D:/Images/TechnipLogo.jpg" Windows. , urlencode():

  <?php  $THEPATHTOYOURIMAGE=urlencode($THEPATHTOYOURIMAGE); ?>
0

All Articles