php 网页ftp 代码二 文件上传
php 网页ftp 代码二 文件上传
<?php
$ftpserver=$_POST[ftpserver];
$ftpport=$_POST[ftpport];
$ftpuser=$_POST[ftpuser];
$ftppassword=$_POST[ftppassword];
$ftp=@ftp_connect($ftpserver,$ftpport);
if(!$ftp){ echo "连接FTP服务器".$ftpserver."的端口".$ftpport."失败";exit;}
$ftp=@ftp_connect($ftpserver,$ftpport);
if(!$rs){ echo "用户名或密码错误,连接FTP服务器失败";exit;}
$curDir=stripslashes($_POST[curDir]);
$localfile=str_replace("$ftp=@ftp_connect($ftpserver,$ftpport]));
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;
}
?>
本文链接:http://www.phprm.com/frame/php1004912.html
收藏随意^^请保留教程地址.