How to pass src to an <img> tag in html from a system drive?
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
, , 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