PHP的FTP学习(四) -PHP实例教程-编程教程
发布时间:2012-7-23 19:52:02 阅读次数:
By Vikram Vaswani
Melonfire
November 07, 2000
以下是代码列表:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
/*
--------------------------------------------------------------------------------
DISCLAIMER:
This is use-at-your-own-risk code.
It is meant only for illustrative purposes and is not meant for PRoduction environments. No warranties of any kind are provided to the user.
You have been warned!
All code copyright Melonfire, 2000. Visit us at http://www.melonfire.com
--------------------------------------------------------------------------------
*/
// function to connect to FTP server
function connect()
{
global $server, $username, $password;
$conn = ftp_connect($server);
ftp_login($conn, $username, $password);
return $conn;
}
// main program begins
// check for valid form entries else print error
if (!$server || !$username || !$password)
{
echo "Form data incomplete!";
}
else
{
// connect
$result = connect();
// action: change directory
if ($action == "CWD")
{
// at initial stage $rdir does not exist
// so assume default directory
if (!$rdir)
{
$path = ".";
}
// get current location $cdir and add it to requested directory $rdir
else
{
$path = $cdir . "/" . $rdir;
}
// change to requested directory
ftp_chdir($result, $path);
}
// action: delete file(s)
else if ($action == "Delete")
{
Melonfire
November 07, 2000
以下是代码列表:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
/*
--------------------------------------------------------------------------------
DISCLAIMER:
This is use-at-your-own-risk code.
It is meant only for illustrative purposes and is not meant for PRoduction environments. No warranties of any kind are provided to the user.
You have been warned!
All code copyright Melonfire, 2000. Visit us at http://www.melonfire.com
--------------------------------------------------------------------------------
*/
// function to connect to FTP server
function connect()
{
global $server, $username, $password;
$conn = ftp_connect($server);
ftp_login($conn, $username, $password);
return $conn;
}
// main program begins
// check for valid form entries else print error
if (!$server || !$username || !$password)
{
echo "Form data incomplete!";
}
else
{
// connect
$result = connect();
// action: change directory
if ($action == "CWD")
{
// at initial stage $rdir does not exist
// so assume default directory
if (!$rdir)
{
$path = ".";
}
// get current location $cdir and add it to requested directory $rdir
else
{
$path = $cdir . "/" . $rdir;
}
// change to requested directory
ftp_chdir($result, $path);
}
// action: delete file(s)
else if ($action == "Delete")
{
网站关键词:千喜网络 云主机租用 服务器托管 CDN加速 虚拟主机 网站空间 域名注册 企业邮局 数据库