I'm getting this error:
Warning: Unable to find ftpbuf 0 in /home/qr/www/test02.php on line 25
Can someone please help me.
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "Connected to server";
}
ftp_chdir($conn_id, $dir);
$dir=ftp_pwd($conn_id);
$list=Array();
$list=ftp_nlist($conn_id, "$dir");
$i=0;
echo "<br><br>Select a file to download:<br>";
echo "<form enctype='multipart/form-data' action=test02.php method=post>";
echo "<input type='hidden' name='function' value='get'>";
echo "<select name='download' size='10' width='150'>\n";
do{
$size=ftp_size ($login_result, $list[$i]);
$temp=ereg_replace("$dir", "", $list[$i]);
$temp=ereg_replace("/", "", $temp);
echo "<option value='$temp'>$temp ($size bytes)</option>\n";
$i++;
}while($list[$i]);
echo "</select>";
echo"<br><input type='submit' name='download' value='DOWNLOAD FILE'>\n";
echo"</form>\n";
function download()
{
$temp_file = tempnam("/tmp", "$temp");
if($temp = fopen($temp_file, "w+"))
{
if(ftp_fget($conn_id, $temp, $temp, FTP_BINARY))
{
print("<br>Download worked." );
rewind($temp);
fpassthru($temp);
}
else
{
echo"<br>Download failed!";
fclose($temp);
}
}
else
{
echo "<br>Fopen failed.";
}
}
switch($function){
case "get";
download($ftp_user_name, $ftp_use_pass, $temp, $dir, $conn_id);
break;
}