近些日子好不轻巧到了笔者们的第三个公文,include.php
它为顺序建设构造起叁个客商界面。”include.php”
包含四个表单,一些PHP代码获取当前的目录列表并将它们存入八个变量$files
,$file_sizes ,and $dirs 第一个表单使用$dirs
产生叁个下拉式目录列表,对应于“action=CWD”。第一个表单使用$files$file_sizes创制二个可用的文件列表,每八个文书使用多个checkbox。这些表单的action对应于”action=Delete”
and
“action=Download”第多个表单用来上传二个文书到FTP站点,如下:—————————————————————————————————————————————————————-当PHP以这种方式选拔到二个文件名,一些变量就产生了,那个变量钦赐文件的分寸,二个一时的文书名以致文件的种类,最早的文本名存在$upfile_name,一旦上传后文件名便存入$upfile中通过那些消息,大家就足以创设以下的语句了:——————————————————————————–ftp_put($result,
$upfile_name, $upfile,
FTP_BINA昂科威YState of Qatar;——————————————————————————–以下是代码列表:——————————————————————————–


—————————————————————————————————————————————————————-/*——————————————————————————–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

function to connect to FTP serverfunction connect(){global $server,
$username, $password;$conn = ftp_connect;ftp_login($conn, $username,
$password);return $conn;}// main program begins// check for valid form
entries else print errorif (!$server !$username !$password){echo “Form
data incomplete!”;}else{// connect$result = connect();// action: change
directoryif {// at initial stage $rdir does not exist// so assume
default directoryif {$path = “.”;}// get current location $cdir and add
it to requested directory $rdirelse{$path = $cdir . “/” . $rdir;}//
change to requested directoryftp_chdir;}// action: delete fileelse if
{ftp_chdir;// loop through selected files and deletefor ($x=0;
$x—————————————————————————————————————————————————————-//
get current location$here = ftp_pwd;/*since ftp_size() is quite slow,
especially when workingon an array containing all the files in a
directory,this section performs an ftp_size() on all the files in the
currentdirectory and creates three arrays.*/// array for files$files =
Array();// array for directories$dirs = Array();// array for file
sizes$file_sizes = Array();// counters$file_list_counter =
0;$dir_list_counter = 0;// check each element of $filelistfor ($x=0;
$xYou are currently working in PHP的FTP学习[转自奥索]_php基础_脚本之家。echo $here; ?>
echo $status; ?>

File upload:


Available files:

Available directories:


发表评论

电子邮件地址不会被公开。 必填项已用*标注