954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Save a webpage?

I would like to make a button that will save the current webpage you are viewing like clicking FILE>SAVE AS in IE, FF, etc. Once clicked you can "precode" the default name of the file based on the variables used in the webpage. Also I if possible I would like to omit certain details on the current webpage from being saved when the save as button is clicked.

So anyone got any ideas on how to make a save as button?

Thanks, Regards X

OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
 

PS: Even possible to change the default name of IE, FF, etc save as button to your variables on the php page.

OmniX
Practically a Master Poster
656 posts since Dec 2007
Reputation Points: 31
Solved Threads: 10
 

Just send a file that represents the page, to the browser.

Some examples can be found here:
http://php.net/manual/en/function.readfile.php

Basically, you're sending the same file, but telling the browser to treat it as a download.

eg:

If the file is example.php

Then in that file, you could have a parameter $_GET['download'].

If it is set to TRUE, then let the browser know that the file is a download.

eg:

<?php

// sample HTML
echo '<p>I am example.php</p>';

?>


To enable that file to be downloaded, put:

<?php

if (isset($_GET['download']) && $_GET['download']) {
// tell browser its a download
header('Content-Disposition: attachment; filename="example.php"');
}

// sample HTML
echo '<p>I am example.php</p>';

?>


Then you just need a add a link on that page:

<a href="index.php?download=1">download</a>
digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You