I want to display an image on a web page using HTML
tag.
I have stored the image on my local drive.
How to achieve this?
Th
Your image should be on a relative path not absolute one.
Say your html file is in D:\myhtml\home.html. Copy the Images folder in myhtml. Then change your code to <img src="Images\TechnipLogo.jpg" />
.
Hope this helps
Well, as there are many issues with different browsers and so with Apache paths config, I tried all the possible ways file: file:// c: c| and none of them worked on my Firefox 57.0 in W7, so there is a fast solution (if you use php). Just call a file "embedIMG.php" with this content:
<?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();
?>
Call this "embedIMG.php" from your img tag:
<img src="embedIMG.php?imgg=THEPATHTOYOURIMAGE">
THEPATHTOYOURIMAGE will be the path to your image "D:\Images\TechnipLogo.jpg", it's better to do it this way "D:/Images/TechnipLogo.jpg" with common slashes on Windows. If you have spaces or special characters in your path you will have to declare it with urlencode() function:
<?php $THEPATHTOYOURIMAGE=urlencode($THEPATHTOYOURIMAGE); ?>