943,895 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4390
  • PHP RSS
Jul 1st, 2009
0

Save a webpage?

Expand Post »
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
Similar Threads
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Jul 1st, 2009
0

Re: Save a webpage?

PS: Even possible to change the default name of IE, FF, etc save as button to your variables on the php page.
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Jul 2nd, 2009
0

Re: Save a webpage?

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 Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. // sample HTML
  4. echo '<p>I am example.php</p>';
  5.  
  6. ?>

To enable that file to be downloaded, put:

php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if (isset($_GET['download']) && $_GET['download']) {
  4. // tell browser its a download
  5. header('Content-Disposition: attachment; filename="example.php"');
  6. }
  7.  
  8. // sample HTML
  9. echo '<p>I am example.php</p>';
  10.  
  11. ?>

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

PHP Syntax (Toggle Plain Text)
  1. <a href="index.php?download=1">download</a>
Last edited by digital-ether; Jul 2nd, 2009 at 12:45 am.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help with php redirect
Next Thread in PHP Forum Timeline: Passsword Strength Checker





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC