Home  >  Article  >  Backend Development  >  php web page ftp code 1_PHP tutorial

php web page ftp code 1_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:571114browse

php web page ftp code

$ftpserver="127.0.0.1";
$ftpport="21";
$ftpuser="anonymous";
$ftppassword="";
if($_POST)
{
$action=$_POST[action];
switch($action)
{
case "open ":
case "change":
$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 FTP server ";exit;}
$curDir=$_POST[curDir];
if($curDir=="") $curDir="/";
if($curDir=="/")
{
$parentDir="/";
}else{
if(strrpos($curDir,"/")==0)
{
$parentDir="/" ;
}else{
  $parentDir=substr($curDir,0,strrpos($curDir,"/"));
}
}
  $arr=ftp_rawlist($ftp, $curDir);
if(count($arr)>1)
{
foreach($arr as $val)
{
if($curDir=="/")
                                                                                                                                                                                                                  $val="/" . trim(strrchr($val," ")); val," "));
}
                                                                                                                                 🎜> $dirlist[]=str_replace("","/",$val);
$filelist[]=str_replace("","/",$val);
}
}
}
break;
case "close":
break;


}

}

Let’s take a look at the WEB page format.



?>

http://www.bkjia.com/PHPjc/445065.html
www.bkjia.com


true

http: //www.bkjia.com/PHPjc/445065.html

php web page ftp code?php $ftpserver=127.0.0.1; $ftpport=21; $ftpuser=anonymous; $ ftppassword=; if($_POST) { $action=$_POST[action]; switch($action) { case open: case change: $ftps...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn