php 网页ftp 代码二 文件上传
$ftpserver=$_post[ftpserver];
$ftpport=$_post[ftpport];
$ftpuser=$_post[ftpuser];
$ftppassword=$_post[ftppassword];
$ftp=@ftp_connect($ftpserver,$ftpport);
if(!$ftp){ echo "连接ftp服务器".$ftpserver."的端口".$ftpport."失败";exit;}
$rs=@ftp_login($ftp,$ftpuser,$ftppassword);
if(!$rs){ echo "用户名或密码错误,连接ftp服务器失败";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 "";
exit;
}else{
echo "";
exit;
}
}else{
echo "";
exit;
}
?>










