Asked  2 Years ago    Answers:  5   Viewed   102 times

What approach could someone suggest to save the current page as an HTML file to the server? In this case, also note that security is not an issue.

I have spent endless hours searching around for this, and have not found a single thing.

Your help is much appreciated, thank you!


Thank you all for your help, it was very much appreciated.



If you meant saving the output of a page in a file, you can use buffering to do that. The function you need to use are ob_start and ob_get_contents.

// Start the buffering //
Your page content bla bla bla bla ...

echo '1';

// Get the content that is in the buffer and put it in your file //
file_put_contents('yourpage.html', ob_get_contents());

This will save the content of the page in the file yourpage.html.

Monday, August 22, 2022

IE8 does not support HTML5. Perhaps IE9 is running in compatibility mode? Press F12 to bring up the developer tools and in the top menu you can change the settings in what mode it is in.

Maybe it is a solution to use a Java or Flash based system for multiple uploads. Also, these will also usually support drag and drop of files.

Monday, August 29, 2022

You should use post request not get request.

var pcontent = document.body.innerHTML;
var url = new URI();

    url: url,
    type: "POST",
    data: {"pcontent": pcontent},
    success: function (data) {
    complete: function () {
    error: function(jqXHR,error, errorThrown) {  
            alert("Something went wrong");
return false;
Wednesday, September 14, 2022

Via JavaScript Strictly, No.

But here are two alternatives, 1 client side and 1 server side.

Force Download via HTM5 link.

Now the HTML5 spec defines a very useful download attribute on hyperlinks that basically allows to force download behavior on client-side, regardless of what comes in Content-Type and Content-Disposition from the server.

Fiddled Here:

<a href="URL" download> Download your Question</a>

Read more here: https://.com/a/15970140/144665

Set Content-Disposition in the header.

Or if you have server side control set Content-Disposition in the header which forces the save dialog.

Read more here: How to encode the filename parameter of Content-Disposition header in HTTP?

Saturday, August 13, 2022

The File API is HTML that would allow you to access data, after which you can manipulate binary blobs in JavaScript, but as written this is not possible in pure JS and HTML based on your requirements.

The big blocker is "saving to a text file." The only way I've been able to do this is by opening up an iFrame that calls a server side language (such as PHP) to set the content type in the header to a type that prompts a download.

Flash and Silverlight are "client" technologies that run outside of the sandbox, which sounds like your only option at this point.

Tuesday, December 20, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :

Browse Other Code Languages