-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftptest.php
56 lines (45 loc) · 1020 Bytes
/
ftptest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?
include "ftp_class.php";
$ftp = new ftp(TRUE);
$ftp->Verbose = TRUE;
$ftp->LocalEcho = TRUE;
if(!$ftp->SetServer("ftp.domain.com")) {
$ftp->quit();
die("Setiing server failed\n");
}
if (!$ftp->connect()) {
die("Cannot connect\n");
}
if (!$ftp->login("login", "password")) {
$ftp->quit();
die("Login failed\n");
}
if(!$ftp->SetType(FTP_AUTOASCII)) echo "SetType FAILS!\n";
if(!$ftp->Passive(FALSE)) echo "Passive FAILS!\n";
$ftp->chdir("apache");
$ftp->cdup();
$ftp->nlist("-la");
$list=$ftp->rawlist(".", "-lA");
if($list===false) echo "LIST FAILS!";
else {
foreach($list as $k=>$v) {
$list[$k]=$ftp->parselisting($v);
}
print_r($list);
}
$filename = "ftpweblog-102a.tar.gz";
if(FALSE !== $ftp->get($filename))
echo $filename." has been downloaded.\n";
else {
$ftp->quit();
die("Error!!\n");
}
$ftp->nlist("-la");
if(FALSE !== $ftp->put($filename, "new-".$filename))
echo $filename." has been uploaded as ".$filename.".bak\n";
else {
$ftp->quit();
die("Error!!\n");
}
$ftp->quit();
?>