Location: PHPKode > projects > mediaIndex > includes/editDir.php
<?php
if (isset($_POST['submit']) && $_POST['submit']=="Save") {
    // handle removed image
    if (isset($_POST['rmimage'])) {
        if (unlink(_DIRIMAGEPATH."/{$GLOBALS['dir']->image}"))
            _addMessage("Removed directory image.");
        if (unlink(_DIRTHUMBPATH."/{$GLOBALS['dir']->thumbimage}"))
            _addMessage("Removed directory thumbnail image.");
        $GLOBALS['dir']->image = "";
    }
    // handle uploaded image
    if (!empty($_FILES['image']) && !empty($_FILES['image']['name'])) {
        if ($GLOBALS['dir']->image = _handleFileUpload(_DIRIMAGEPATH,$_FILES['image'])) {
            if (is_file(_DIRTHUMBPATH."/{$GLOBALS['dir']->thumbimage}")) {
                if (unlink(_DIRTHUMBPATH."/{$GLOBALS['dir']->thumbimage}"))
                    _addMessage("Removed directory thumbnail image.");
            }
            _addMessage("Image uploaded successfully.");
        } else {
            _addMessage("There was an error uploading image file.");
        }
    }

    $GLOBALS['dir']->title = $_POST['title'];
    $GLOBALS['dir']->desc = $_POST['desc'];

    $GLOBALS['dir']->saveMetadata();
}

echo "<div class=\"edit\" style=\"display:none;\" id=\"editForm\">\n";
_printSubtitle("Editing directory ".$GLOBALS['dir']->path);

echo "<form method=\"POST\" enctype=\"multipart/form-data\">";
echo "<table>\n";
echo "<tr><td width=\"20%\">Title: </td><td><input type=\"text\" name=\"title\" size=\"40\" maxlength=\"255\" value=\"".stripslashes($GLOBALS['dir']->title)."\" /></td></tr>\n";
echo "<tr><td width=\"20%\">Description: </td><td><textarea name=\"desc\" rows=\"15\" cols=\"50\">".stripslashes($GLOBALS['dir']->desc)."</textarea></td></tr>\n";
echo "<tr><td width=\"20%\">Upload Image: </td><td><input type=\"file\" name=\"image\" size=\"40\" maxlength=\"255\" /></td></tr>\n";
if (!empty($GLOBALS['dir']->thumbimage)) {
    echo "<tr><td>Current Image:</td><td>";
    echo "<img src=\""._DIRTHUMBURL."/".$GLOBALS['dir']->thumbimage."\" alt=\"{$GLOBALS['dir']->title}\" align=\"left\">";
    echo "&nbsp;<br /><input type=\"checkbox\" id=\"rmimage\" name=\"rmimage\" /><label for=\"rmimage\">Remove this image</label>\n";
    echo "</td></tr>\n";
}
echo "<tr><td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"Save\" /></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "</div>\n";
?>
Return current item: mediaIndex