I'm quite new to php and need some help with this.
I have a website with php pages that extract data from a MySQL database, create a couple of charts (jpgraph) and include a few small images.
I need to create a Save button that allows the user to select where on his hard drive to save the file, and then saves the file as html, including charts and images.
In other words, I need to emulate the File, Save As, Save Web Page feature in IE from a button and also to make it work on all browsers.
Can someone please point me in the right direction.
Many thanks
Peter
Save web page to disk
Moderator: General Moderators
- Fredix
- Forum Contributor
- Posts: 101
- Joined: Fri Jul 18, 2003 2:16 pm
- Location: Wehr (Eifel) Germany
- Contact:
Sorry I can't really help you out but why don't you just rely on the browser's File->Save as ?
To write data to a clients machine you probably need Java. This can't be done through simple means like JS or HTML.
Another alternative is that using your php-script you create a copy of the whole page, zip or rar it, and put it in a tmp directory. And make a download link to this file.
To write data to a clients machine you probably need Java. This can't be done through simple means like JS or HTML.
Another alternative is that using your php-script you create a copy of the whole page, zip or rar it, and put it in a tmp directory. And make a download link to this file.
Using a series of header()'s you might get this to work.
In short;
Upon pressing the button, the user is transfered to a new page holding the appropiate header()'s, starting a download of say the html. After the download is initiated, header() to the next page to download image #X, then the next...
Hope you follow me here, as i have not tested multible downloading myself.
Some more pointers;
You need to generate the actual html on-the-fly (you need a file to download, php is just server side remember, so any data is not saved per se.)
Hope i gave you some more ideas.
Code: Select all
<?php
// for a powerpoint file
header("Content-type: application/ppt");
header("Content-Disposition: attachment; filename=downloaded.ppt");
/* ... output ppt file ... */
?>Upon pressing the button, the user is transfered to a new page holding the appropiate header()'s, starting a download of say the html. After the download is initiated, header() to the next page to download image #X, then the next...
Hope you follow me here, as i have not tested multible downloading myself.
Some more pointers;
You need to generate the actual html on-the-fly (you need a file to download, php is just server side remember, so any data is not saved per se.)
Hope i gave you some more ideas.