Save a webpage?

Reply

Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Save a webpage?

 
0
  #1
Jul 1st, 2009
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
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Re: Save a webpage?

 
0
  #2
Jul 1st, 2009
PS: Even possible to change the default name of IE, FF, etc save as button to your variables on the php page.
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Save a webpage?

 
0
  #3
Jul 2nd, 2009
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:

  1. <?php
  2.  
  3. // sample HTML
  4. echo '<p>I am example.php</p>';
  5.  
  6. ?>

To enable that file to be downloaded, put:

  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:

  1. <a href="index.php?download=1">download</a>
Last edited by digital-ether; Jul 2nd, 2009 at 12:45 am.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC