0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by digital-ether
0

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

0

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.

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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.