Location: PHPKode > scripts > Edit File Tags > edit-file-tags/example.php


//Begin class. Send the file for read
$edit = new EditFileTags('http://www.ianitsky.com/files/phpclasses/EditDocumentTags.rtf');

if ($_POST) {//If post save the document
   //After submitting the data in the form send create a string already formatted in the way we want.
   $string = $edit->write($_POST['tag']);
   header('Content-Type: application/msword');
	 header('Content-Disposition: inline, filename=ianitsky_test.rtf');
	 $string = str_replace( "\n", " \par ", $string);
	 $string = str_replace( "\t", "        ", $string);
	 echo $string;
} else { //Else create the form
  //Read the document and return the tags for form
  $fileTags = $edit->read();
  if ($error = $edit->getLastError()) {
    echo $error;
      <center><h1>Edit file tags example</h1></center>
          <form action="" method="POST">
              //Create form
              foreach ($fileTags as $key => $value) {
                echo '<tr>';
                echo '<td>';
                echo $value . ':';
                echo '</td>';
                echo '<td>';
                echo '<input type="text" name="tag[]" />';
                echo '</td>';
                echo '</tr>';
                <input type="submit" value="Send">
Return current item: Edit File Tags