Asked  8 Months ago    Answers:  5   Viewed   41 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!

Edit

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

 Answers

89

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.

<?php
// Start the buffering //
ob_start();
?>
Your page content bla bla bla bla ...

<?php
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.

Wednesday, March 31, 2021
 
CBroe
answered 8 Months ago
23

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.

Wednesday, March 31, 2021
 
Bono
answered 8 Months ago
35

Two things:
1. Is the form set to:

<form method="POST" enctype="multipart/form-data" action="INSERT ACTION">

2. Is the folder your posting the file to, is it set to 777?

Wednesday, March 31, 2021
 
Rocket
answered 8 Months ago
40

You can use document.getElementById("myID").innerHTML, like this:

var = tabelaContent; 

tabelaContent = document.getElementById("tabela").innerHTML
localStorage.setItem("tabelaContent",tabelaContent);
Wednesday, October 20, 2021
 
Vincent
answered 1 Week ago
99

There are some solutions out there, like for example display property toggle, or render inside hidden element.

Solution 1

Quickly toggle visibility property

const el = document.querySelector('.specific');
el.style.display = "block"; // or any other property, like opacity, visibility...
html2canvas(el, {...}).then((canvas) => {
   el.style.display = "none";
};

Solution 2

Wrap your div (and make it visible) inside an invisible wrapper

<div style="position: absolute; opacity: 0; pointer-events:none;">
    <div class="specific"></div>
</div>

or

<div style="overflow: hidden; height: 0;">
    <div class="specific"></div>
</div>

Solution 3

Using html2canvas onclone callback function you can modify object passed to renderer (I think it's the best solution)

html2canvas(document.querySelector('.specific'), {
    onclone: function(doc){
        doc.style.display = 'block';
        // or doc.style.opacity = '1', doc.style.visibility = 'visible' ...
    },
    onrendered: function(canvas) {
        theCanvas = canvas;
        Canvas2Image.saveAsPNG(canvas); 
    }
});
Saturday, October 23, 2021
 
Martin Thoma
answered 5 Days ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share