php 網頁ftp 代碼一_PHP教程

來源:互聯網
上載者:User
php 網頁ftp 代碼

$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 "串連FTP伺服器".$ftpserver."的連接埠".$ftpport."失敗";exit;}
$rs=@ftp_login($ftp,$ftpuser,$ftppassword);
if(!$rs){ echo "使用者名稱或密碼錯誤,串連FTP伺服器失敗";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," "));
}else{
$val=$curDir . "/" . trim(strrchr($val," "));
}

$file_size=ftp_size($ftp,$val);
if($file_size==-1)
{//為目錄
$dirlist[]=str_replace("\","/",$val);
}else{
$filelist[]=str_replace("\","/",$val);
}
}
}
break;
case "close":
break;


}

}

下面來看看WEB頁面形式了.


?>


http://www.bkjia.com/PHPjc/445065.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445065.htmlTechArticlephp 網頁ftp 代碼 ?php $ftpserver=127.0.0.1; $ftpport=21; $ftpuser=anonymous; $ftppassword=; if($_POST) { $action=$_POST[action]; switch($action) { case open: case change: $ftps...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.