473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Saving a page into html in php

28
I ahve a problem..Help me....

When user submits a form, a page is displayed with all the submitted details. But my real problem is how do i save the same page into .htm/.html format and store it on the disc at the same time when the user sees the page...Thanks...
Jan 30 '07 #1
5 1643
Atli
5,058 Expert 4TB
You can save all your output by doing something like this.

[PHP]<?php

// Set the path to the file you want to save
$filename = "Path to the file you want to save";
// Note: This does not create any folders, they must exists before you do this.

// Function to handle the output on flush
function ob_flush($buffer)
{
// Open your file and write the buffer
$fh = fopen($filename, "w");
fwrite($fh, $buffer);
fclose($fh);

// print the buffer to the browser
print $buffer;
}

// Start buffering the output
ob_start("ob_flush");

/** Whatever you want to output, put it here. **/

// Stop buffering and send the buffer to the ob_flush function
ob_end_flush();

?>[/PHP]

Hope this helps
Jan 30 '07 #2
syam
28
Thanks... for your reply.....But thisn't what i mean

The above code is for already existing file. But this isn't what i mean. I have to save the page at the same time the user is viewing the page. For example if u r looking some web page and then itself u can save the page using SaveAs in your desired format like doc/rtf/html etc. I want that kind of saving using php.
Jan 30 '07 #3
Atli
5,058 Expert 4TB
You want the user to be able to save the page he's viewing to his hard drive?

Im not sure thats possible. That would require the code to have access to the users local drive, and that poses a major security threat.
Jan 30 '07 #4
ronverdonk
4,258 Expert 4TB
You would not want to write to the user's pc! As Atli says, you run a huge security risk when it is possible for servers writing files to clients. Hackers heaven!

The usual procedure is to either let the user print his screen, using a screen button with a javascript print command, or send an email with the data.

Ronald :cool:
Jan 30 '07 #5
Motoma
3,237 Expert 2GB
There are ways to make pages bring up a Save File dialog instead of rendering in your browser, but it doesn't sound like that is what you want.

If this is what you are looking for, post back, and I will give you some code.
Jan 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lovely Angel For You | last post by:
Dear Friends Hope you all doing great. I have this problem. When I try to save any ASP page, I get the message that "The page will not save correctly". Even though I go ahead and when I go...
0
by: William Morris | last post by:
We have a number of clients using a web application. Each client sees a slightly different version of, say, a contact input page. As a simple example, Client #1 sees demographics, plus religious...
1
by: Sachin | last post by:
Hi, I am trying to save a file using the following code. MessageBox("Saving file","",MB_OK); _Module.m_pWebBrowser->get_Document(&pDisp); spHTMLDocument2 = pDisp; IPersistFile* pFile ...
3
by: James | last post by:
Situation: I have a page, built using document.write(). When I hit 'save as', IE goes and saves the contents of 'about:blank' to that file, rather than saving the HTML it's displaying in the...
6
by: Vijay | last post by:
I need to generate HTML files based on the some codes. One HTML file per code. I have the link (ex:http://123.234.345.456/WebPages/GetTestData.aspx?SomeCode=25), by passing the code as parameter I...
3
by: Clay Black | last post by:
I need to find a way to save an HTML page to the IIS server. What I need is to have a button that once it is clicked the current page being displayed is saved to a location on the local IIS...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
7
by: Bam | last post by:
Hey gang. Is there a way, to automatically save a page that is db driven, as a page that contains html? i would like a page like http://tournamentsbyeck.com/past_standings3.asp to be...
3
by: ajaycfd | last post by:
hi all, I need to implement the following functionality in asp. I have got an asp page which renders some html onto the browser.Now instead of rendering the html to the browser i should save...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.