Letting a user download a webpage's html file

I was experimenting with an <a> tag and wanted to be able to let a user download the pen’s html. I tried a lot, but it didn’t work.

https://codepen.io/Glaurung/pen/YzPEpxR?editors=1000

Can you please tell me how I can make the html a downloadable file? Thanks.

@ConnerOw1115, did you try this?

https://www.w3schools.com/tags/att_a_download.asp

Hi,

here is a link

Only the full source button works now. On the other one I have to find the bug… :frowning:

this is the php code:

<?php
$pathinfo = pathinfo($_GET["fileName"]);
show_source($pathinfo["basename"]);
?>

and here is the code of the button:

<a class="btn btn-primary btn-lg" id="fullSource" href="showfullsource.php?fileName=<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" role="button" target="_blank">Full Source</a>

only the href attribute important, everything else are style only…
Read more in php manual
I don’t know any front-end method like the above but I will look around, this challenge interest me too.

Okay, that works, but I can’t seem to be able to let any user download my computer’s files and I need, when a user clicks on the link, to let them download the pen’s html.

Use Github instead of pen.
From Github anyone can download your files if your repositories are public. This is the easiest way.

Okay. I’ll try that later.

I think this may be what you were looking for @ConnerOw1115

Quick pen using download