C:\xampp\contrib\ftp-mit-php.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
<?php
$host
="localhost";
$user="zaphod";
$password="blabla";

// Herstellen der Basis-Verbindung
$conn_id ftp_connect($host); 

// Einloggen mit Benutzername und Kennwort
$login_result ftp_login($conn_id$user$password); 

// Verbindung überprüfen
if ((!$conn_id) || (!$login_result)) { 
        echo 
"Ftp-Verbindung nicht hergestellt!";
        echo 
"Verbindung mit $host als Benutzer $user nicht möglich"
        die; 
    } else {
        echo 
"Verbunden mit $host als Benutzer $user";
    }

print 
"<br>";
$path="/";
$dir "";
///// List  
$files=ftp_nlist($conn_id"$path");
foreach (
$files as $file) {
 
$isfile ftp_size($conn_id$file); 
 if(
$isfile == "-1") { // Ist ein Verzeichnis
  
print $file."/ [DIR]<br>";
 }
 else {
  
$filelist[(count($filelist)+1)] = $file// Ist eine Verzeichnis
  
print $file."<br>";
 }
}


///// Upload 
// ftp_put($conn_id, $remote_file_path, $local_file_path, FTP_BINARY);
 
///// Download
// ftp_get($conn_id, $local_file_path, $remote_file_path, FTP_BINARY); 

///// Löschen einer Datei
// ftp_delete ($conn_id, $remote_file_path); 


// Schließen des FTP-Streams
ftp_quit($conn_id); 
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586