Interspire Product Knowledge Base

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Export to PDF

User Opinions (1 vote)

0% thumbs up 100% thumbs down

How would you rate this answer?



Thank you for rating this answer.

How can I load the contents of a file, edit it and then save it again?

You can use DevEdit to load a HTML file, edit it and then save it again quite easily.

Here's some PHP code that will load a file called content.html and show its HTML in the DevEdit control. You can then change the content and it will be saved back to the content.html file:

<?php

include("de/class.devedit.php");

$myDE = new DevEdit;
$myDE->SetName("myDevEditControl");
SetDevEditPath("/de");
$myDE->SetDocumentType(de_DOC_TYPE_HTML_PAGE);

if(@$_POST["save"] == "true")
{
$fileContent = $myDE->GetValue(false);
$fp = fopen("content.html", "w");
fputs($fp, $fileContent);
fclose($fp);
echo "Content.php saved!<br><br><a href='test.php'>Continue</a>";
}
else
{
$fp = fopen("content.html", "rb");
while(!feof($fp))
{
$data .= fgets($fp, 1024);
}
$myDE->SetValue($data);
?>
<form action="test.php" method="post">
<input type="hidden" name="save" value="true">
<?php $myDE->ShowControl(400, 300, "my_image_dir"); ?>

<input type="submit" value="Save">
</form>
<?php
}
?>

Note: This is an example. You may have to change parts of the code above to get it to work.

Related Articles

No related articles were found.

Attachments

No attachments were found.

Powered by Interspire Knowledge Manager - World's #1 Best Selling FAQ and Knowledge Base Software