dev.vini 0 Newbie Poster

her is the code and please tll me that how can i save the directory file in same location that is opend in textarea pls tell me soon

<?php
if(empty($_GET['dir']))
	$currdir = '.';
else
	$currdir = $_GET['dir'];

// open this directory
$myDirectory = opendir($currdir);

// get each entry
while($entryName = readdir($myDirectory)) 
	{
	 $dirArray[] = $entryName;
	 $entryName;
	//echo '<pre>';
	//print_r($dirArray);
    }

// close directory
closedir($myDirectory);

//	count elements in array
$indexCount	= count($dirArray);
//Print  ("$indexCount files<br>\n");


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>List Box </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function submitform()
{
	document.frm.submit();
}
//-->
</SCRIPT>
</HEAD>

<BODY>
<table height="400" width="700" border="1" align="center">
<tr><td>

<table>
		<tr>
		   <td><b>Path: </b><?php echo getcwd(); ?>\<?php  echo  $fileName = $_GET['file'] ; ?></td>
		</tr>
		<tr>
		<td>
		   <form method="get" name="frm" >
	<table>
		<select name="file" multiple size="20" onDblClick="submitform();" >
			<?php 

				// loop through the array of files and print them all
				for($index=0; $index <= $indexCount; $index++) 
					{
						if (substr($dirArray[$index], 0, 1) != ".")
						{ // don't list hidden files
						echo '<option  value="'.$dirArray[$index].'" >'.$dirArray[$index].'</option>';			
						}
				    }
			?>
		</select>
	</table>
	 
	</td>
	</tr>
	</table>
	<div></div>
	<input type="hidden" name="dir" value="<?php echo $currdir; ?>">
	</form>
	</td>

	<td>

	<table>
	<tr>
	<tr><td><b>File Name : </b><?php  echo $fileName ; ?>		</td></tr>
	<td colspan="2">
		<textarea rows="20" cols="100"  id="txtHint" >
			<?php 
			// here we have to show the file content

					
			$file = fopen($fileName, "r") or exit("Unable to open file!");
			//Output a line of the file until the end is reached
			while(!feof($file)) // test for end of file
			  {
			  echo  fgets($file) ;
			  }
			fclose($file);

			?>
		</textarea>
		</td>
	</tr>
		<tr>
			<td>
			<form action="fil.php?filename=<?php echo $fileName; ?>" method="post" name="sform">
			  <input type="submit"  value="save" onclick=" return check();") >
			</form>
			</td>
			<td>
			  <input type="button" value="Cancel" onClick="history.back()">
			</td>
		</tr>
</table>
</td></tr>
</table>
</body>
</HTML>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.