Save as .mhtml does not save my images

Started by giomach, June 20, 2024, 12:14:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

giomach

<html>

<head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<title>Why doesn't "Save as Webpage, Single File (*.mhtml)" include the image in the saved file?</title>
</head>

<body>

<p>Here's an image.<br>
It has a relative url.<br>
It shows up when the page is opened in Chrome.<br>
But when the webpage is saved as .mhtml and reopened in Chrome the image is not found.<br>
In the source of the .mhtml, the relative url has been replaced by its absolute url on the local machine.<br>
The .mhtml file contains what appears to be the image in base64 encoding.  But it's not used.<br>
Why does that happen?  How do I prevent it?</p>

<p><img src="leachtaban.jpg" alt="leachtaban" width="400" /></p>

</body>

</html>


giomach

Well, it seems that local image files are not saved in a mhtml file — wikipedia describes MHTML as "a Web archive file format used to combine, in a single computer file, the HTML code and its companion resources (such as images) that are represented by external hyperlinks in the web page's HTML code." (my emphasis).

Or rather, the local images are embedded in the mhtml in base64 encoding, and associated there with a pseudo-local url, but when a browser encounters this type of url, it acts as if the image can't be found.  Wouldn't it be reasonable to expect that a browser (or an extension) on finding a local url would convert the embedded base64 code and show the image? Probably there's some security vulnerability.

Of course the webpage and its images will all go on the internet when it's finished, but while you're developing it on your local machine and you want to show it to someone who's not very computer-savvy, the restriction is a real (and unexpected) nuisance.