简体   繁体   中英

Is it possible to load image data and display in html with hideing the src url

I want to display images on html but don't want to set the src attribute to the full url. Beacase the image src url can be displayed by browsers debug windows and I want to hide them from client.

I serve the image via a wcf server.

I've tried to use canvases but toDataUrl throws security error on many browsers. Is there any other way to hide the url from client. Is this the best approach?

您可以通过直接在css / html中将它们转换为base 64格式来嵌入图像...

It doesn't matter if you hide the source and I don't even know if that's possible. If a user is smart enough to open the inspector to find the source, they can just right click the image and copy the link address.

<?php
$file = "Tom-and-Jerry.jpg";
if($fp = fopen($file,"rb", 0))
{
   $imgContent = fread($fp,filesize($file));
   fclose($fp);
   $imgBase64Content = base64_encode($imgContent);
}
?>
<img src="data:image/jpeg;base64,<?php echo $imgBase64Content?>" alt="Tom & Jerry"/>

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