$ftpserver=$_POST[ftpserver];
$ftpport=$_POST[ftpport];
$ftpuser= $_POST[ftpuser];
$ftppassword=$_POST[ftppassword];
$ftp=@ftp_connect($ftpserver,$ftpport);
if(!$ftp){ echo "Connect 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 the FTP server";exit;}
$curDir=stripslashes($_POST[curDir]);
$localfile=str_replace("","/",stripslashes($_POST[ file1]));
if($localfile)
{
$filename=substr(strrchr($localfile,"/"),1);
if($curDir== "/")
{
$remotefile=$curDir.$filename;
}else{
$remotefile=$curDir."/".$filename;
}
$ rs=ftp_put($ftp,$remotefile,$localfile,FTP_ASCII);
if($rs)
{
echo "<script>alert('File uploaded successfully');history.back( );</script>";
exit;
}else{
echo "<script>alert('Failed to upload file');history.back();</script>" ;
exit;
}
}else{
echo "<script>alert('No file uploaded');history.back();</script>" ;
exit;
}
?>