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

require_once('EditFileTags.class.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;
  }
?>
    <html>
    <head>
    </head>
      <body>
      <center><h1>Edit file tags example</h1></center>
        <table>
          <form action="" method="POST">
            <?php
              //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>';
              }
            ?>
            <tr>
              <td>
                <input type="submit" value="Send">
              </td>
            </tr>
          </form>
        </table>
      </body>
    </html>
<?php
  }
?>
Return current item: Edit File Tags