<?php 	
  			$curpath=str_replace("\\\\","/",$_POST['curpath']);
			//$curpath=$_POST['curpath'];
		//echo "curpath:".$curpath." OPT:".$_POST['opt'];
		//exit();
	$filepath="";
	
		
		if($_POST['opt']==0)   //add file
		{
		     if($_POST['folders']=="thisfolder") //if current folder is selected
			 {
			  $filepath=$curpath."/".$_FILES['uploadfile']['name'];
			 }
			 else
			 {
			 $filepath=$_POST['folders'].$_FILES['uploadfile']['name'];
			 }
			 
			 if(file_exists($filepath))
			 {
			  unlink($filepath);
			 }
			// echo $filepath;
			 copy($_FILES['uploadfile']['tmp_name'],$filepath);
		}
		else if($_POST['opt']==1)   //file rename
		{
			$oldname=$curpath."/".$_POST['existname'];
			$newname=$curpath."/".$_POST['newname'];		
						
			rename($oldname,$newname);
		}
		else if($_POST['opt']==2)  //folder rename
		{
		
			$oldname=$curpath."/".$_POST['existname'];
			$newname=$curpath."/".$_POST['newname'];	
						
			rename($oldname,$newname);
		}
		else if($_POST['opt']==3)   //new folder
		{
			if($_POST['folders']=="thisfolder")
			{
			  $filepath=$curpath."/".$_POST['newname'];
			}
			else
			{
			  $filepath=$_POST['folders']."/".$_POST['newname'];;
			}
			//echo "FILEPATH=".$filepath;
			//exit();
			mkdir($filepath,0777);
		}
		
?>
<script language="javascript">
	location.assign("FolderList.php?dir1=<?php echo $curpath ?>");
</script>