威斯尼斯人官网PHP的FTP学习[转自奥索]_php基础_脚本之家


Available files:

—————————————————————————————————————————————————————-/*——————————————————————————–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 echo $here; ?>
echo $status; ?>

Available directories:


File upload:


明天终究到了作者们的第多个文件,include.php
它为顺序创设起三个客户分界面。”include.php”
包含两个表单,一些PHP代码获取当前的目录列表并将它们存入八个变量$files
,$file_sizes ,and $dirs 第一个表单使用$dirs
发生叁个下拉式目录列表,对应于“action=CWD”。第1个表单使用$files$file_sizes创造三个可用的公文列表,每三个文书使用多少个checkbox。那个表单的action对应于”action=Delete”
and
“action=Download”第多个表单用来上传三个文件到FTP站点,如下:—————————————————————————————————————————————————————-当PHP以这种情势收受到八个文本名,一些变量就发生了,这几个变量钦命文件的分寸,一个不经常的文书名以至文件的种类,最早的文书名存在$upfile_name,豆蔻梢头旦上传后文件名便存入$upfile中通过那么些音信,大家就足以创立以下的语句了:——————————————————————————–ftp_put($result,
$upfile_name, $upfile,
FTP_BINAMuranoY卡塔尔(قطر‎;——————————————————————————–以下是代码列表:——————————————————————————–

发表评论

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

相关文章