Dear all,

i have a php script to download list of files from server. it is working well, when i type the file address. but i want to get address of file from user.

i have a html page where user select Folder and Sub Folder name to download file list. and submit the page. the folder and Sub Folder name will be sent via POST method to other page where is the my download list script.

when i put the received variables in the script it doesn't work. it show a error message the the dir not found.

but when i type the address in the script it works.

i have checked that variables which is receiving from another page is Right.

Please help me to slove it.

my script is :

<?php 

$folder=$_POST['folder'];
$sfolder=$_POST['sfolder'];

//echo $folder;
//echo $sfolder;


$rec = opendir("$folder/$sfolder");

if($rec = opendir) {

	echo"<b><u>Directory have these Files & Folders:</u></b>";
	
	echo "<select>
	<option>Select File </option>";

	while(false !== ($dir = readdir($handle))) {
		

		echo"<option>$dir</option>";
		
	}
	echo"</select>";
	
	closedir($rec);
}

?>
<?php 

$folder=$_POST['folder'];
$sfolder=$_POST['sfolder'];

//echo $folder;
//echo $sfolder;


$rec = opendir("$folder/$sfolder");

if($rec = opendir) {

echo"<b><u>Directory have these Files & Folders:</u></b>";

echo "<select>
<option>Select File </option>";

while(false !== ($dir = readdir($handle))) {


echo"<option>$dir</option>";

}
echo"</select>";

closedir($rec);
}

?>
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.