$ftpserver=$_POST[ftpserver];
$ftpport=$_POST[ftpport];
$ftpuser=$_POST[ftpuser];
$ftppassword=$_POST[ftppassword];
$ftp=@ftp_connect($ftpserver,$ftpport);
If(!$ftp){ echo "Connection to FTP server".$ftpserver."Port".$ftpport."Failed";exit;}
$rs=@ftp_login($ftp,$ftpuser,$ftppassword);
If(!$rs){ echo "Incorrect username or password, failed to connect to FTP server";exit;}
$targetDir=str_replace("\","/",stripslashes($_POST[targetDir]));
$filename=substr(strrchr($_POST[filelist],"/"),1);
echo $filename;
// exit;
If(substr($targetDir,strlen($targetDir)-1)=="/")
{
$rs=@ftp_get($ftp,$targetDir.$filename,$_POST[filelist],FTP_ASCII);
}else{
$rs=@ftp_get($ftp,$targetDir."/".$filename,$_POST[filelist],FTP_ASCII);
}
If($rs)
{
If(substr($targetDir,strlen($targetDir)-1)=="/")
{
echo "<script>alert('The file downloaded successfully, the path of the file on this machine is [".$targetDir.$filename."]');window.close();</script>";
}else{
echo "<script>alert('The file downloaded successfully, the path of the file on this machine is [".$targetDir."/".$filename."]');window.close();</script>" ;
}
Exit;I am
}else{
echo "<script>alert('File download failed, please check whether the target folder exists, the source file is [".$_POST[filelist]."]');window.close();</script>" ;
exit;
}
?>