$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 "<script>alert('上传文件成功');history.back();</script>";
exit;
}else{
echo "<script>alert('上传文件失败');history.back();</script>";
exit;
}
}else{
echo "<script>alert('没有选择上传文件');history.back();</script>";
exit;
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号