Click to See Complete Forum and Search --> : Working with Files
focus310
04-23-2007, 03:33 AM
Hello:
After a script finishes processing a form, I would like to take the web page which it produces and save it as an HTML file.
Can I do this? And if so, how?
Thank you for the help.
MrCoder
04-23-2007, 05:03 AM
I think your looking for ob_start(), ob_get_clean() and the basic fopen(), fwrite() and fclose() functions?
focus310
04-23-2007, 06:39 AM
Hi,
I'm not quite sure what I need. All I want to do is process a script and save the web page which displays the results as a file.
When I read about fopen(), it sounded to me that the file already exists. I'm trying to create a brand new file.
Will this function create a new file?
Thanks.
MrCoder
04-23-2007, 07:35 AM
Yes by passing "w" as the second parameter.
<?php
ob_start();
?>
<h1>Place your form output here, this will get saved in the page.html file</h2>
<?php
$html = ob_get_clean();
$file = fopen("page.html", "w");
fwrite($file, $html);
fclose($file);
?>
focus310
04-23-2007, 08:21 AM
Thank you for the info. I'll give it a try.