首页  >  文章  >  后端开发  >  php 网页ftp 代码二 文件上传_PHP教程

php 网页ftp 代码二 文件上传_PHP教程

WBOY
WBOY原创
2016-07-20 11:05:551020浏览

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 "<script>alert('上传文件成功');history.back();</script>";
      exit;
     }else{
      echo "<script>alert('上传文件失败');history.back();</script>";
      exit;
     }
    
    }else{
      echo "<script>alert('没有选择上传文件');history.back();</script>";
      exit;
    }
?>


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445066.htmlTechArticlephp 网页ftp 代码二 文件上传 ?php $ftpserver=$_POST[ftpserver]; $ftpport=$_POST[ftpport]; $ftpuser=$_POST[ftpuser]; $ftppassword=$_POST[ftppassword]; $ftp=@ftp_connect($ftp...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn