Home >Backend Development >PHP Tutorial >PHP web page ftp code four download file_PHP tutorial

PHP web page ftp code four download file_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:07:111191browse

php web page ftp code 4 download file

$ftpserver=$_POST[ftpserver];
$ftpport=$_POST[ftpport];
$ftpuser=$_POST[ftpuser];
$ftppassword=$_POST[ftppassword];
$ftp=@ftp_connect($ftpserver,$ftpport);
If(!$ftp){ echo "Connection 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;}
$targetDir=str_replace("\","/",stripslashes($_POST[targetDir]));
$filename=substr(strrchr($_POST[filelist],"/"),1);
echo $filename;
// exit;
If(substr($targetDir,strlen($targetDir)-1)=="/")
{
$rs=@ftp_get($ftp,$targetDir.$filename,$_POST[filelist],FTP_ASCII);
}else{
$rs=@ftp_get($ftp,$targetDir."/".$filename,$_POST[filelist],FTP_ASCII);
}
If($rs)
{
If(substr($targetDir,strlen($targetDir)-1)=="/")
{
echo "<script>alert('The file downloaded successfully, the path of the file on this machine is [".$targetDir.$filename."]');window.close();</script>";
      }else{
echo "<script>alert('The file downloaded successfully, the path of the file on this machine is [".$targetDir."/".$filename."]');window.close();</script>" ;
}
Exit;I am
}else{
echo "<script>alert('File download failed, please check whether the target folder exists, the source file is [".$_POST[filelist]."]');window.close();</script>" ;
exit;
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630442.htmlTechArticlephp web page ftp code four download file?php $ftpserver=$_POST[ftpserver]; $ftpport=$_POST[ ftpport]; $ftpuser=$_POST[ftpuser]; $ftppassword=$_POST[ftppassword]; $ftp=@ftp_connect($ftp...
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