Location: PHPKode > projects > NetLink > netlink_os/rename.php
<h3>Rename a File</h3>

<?php
extract($_GET);
if ($submit)
{
  if ($old_name==$new_name)
  {
	echo "<script type='text/javascript'>\n";
	echo 'alert("Warning: Cannot change Filename of $old_name!\nOld Name and New Name are the same!")\n';
	echo "</script>";
  }
  else
  {
    echo "Changing File Name of <b>$old_name</b> to <b>$new_name</b>...";
    $user=$_SESSION['login'];
	$rnm=rename("Users/$user/$old_name", "Users/$user/$new_name");
	if ($rnm)
	{
		echo "<br/><br/>\n<b>$old_name Renamed to $new_name!</b>";
  		$file=$new_name;
	}
	else
		echo "File System Error: Cannot rename File!\n<br/>\n<br/>\nContact your system admisistrator!";
   include("options.php");
	echo "<hr color='#000000'/>";
  }
}
else
{
echo "<div style='font-size:10pt;'>";
echo "Renaming allows you to change the name of a file that is uploaded on your account. Just fill out the form";
echo "below and press <b>Change Name</b> to change the name of your file.";
echo "<br/><br/>";
echo "<form method='post' action='?id=rename&file=$file'>";
echo "<table summary='rename_file' border='0'>";
echo "<tr>";
echo "<td>Old Name:</td>";
echo "<td style='border:2px solid black;'>";
echo "$file";
echo "</td>";
echo "<input type='hidden' value='$file' name='old_name' id='old_name'/>";
echo "</tr>";
echo "<tr>";
echo "<td>New Name:</td>";
echo "<td><input type='text' name='new_name'/></td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan='2'><br/>";
echo "<input type='submit' name='submit' value='Change Name'/>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "</div>";
}
?>
</body>
</html>
Return current item: NetLink