reference/ftp/examples.xml
4d1c34c9b7a30cfc3a59641122c707a2812cfed7
...
...
@@ -1,9 +1,10 @@
1
-
<?xml version="1.0" encoding="iso-8859-1"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3

4
4
<chapter xml:id="ftp.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
5
&reftitle.examples;
6
6
<section xml:id="ftp.examples-basic">
7
+
<title>Basic usage</title>
7
8
<para>
8
9
<example>
9
10
<title>FTP example</title>
...
...
@@ -11,32 +12,32 @@
11
12
<![CDATA[
12
13
<?php
13
14
// set up basic connection
14
-
$conn_id = ftp_connect($ftp_server);
15
+
$ftp = ftp_connect($ftp_server);
15
16

16
17
// login with username and password
17
-
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
18
+
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
18
19

19
20
// check connection
20
-
if ((!$conn_id) || (!$login_result)) {
21
-
echo "FTP connection has failed!";
22
-
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
23
-
exit;
24
-
} else {
25
-
echo "Connected to $ftp_server, for user $ftp_user_name";
26
-
}
21
+
if ((!$ftp) || (!$login_result)) {
22
+
echo "FTP connection has failed!";
23
+
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
24
+
exit;
25
+
} else {
26
+
echo "Connected to $ftp_server, for user $ftp_user_name";
27
+
}
27
28

28
29
// upload the file
29
-
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
30
+
$upload = ftp_put($ftp, $destination_file, $source_file, FTP_BINARY);
30
31

31
32
// check upload status
32
33
if (!$upload) {
33
-
echo "FTP upload has failed!";
34
-
} else {
35
-
echo "Uploaded $source_file to $ftp_server as $destination_file";
36
-
}
34
+
echo "FTP upload has failed!";
35
+
} else {
36
+
echo "Uploaded $source_file to $ftp_server as $destination_file";
37
+
}
37
38

38
-
// close the FTP stream
39
-
ftp_close($conn_id);
39
+
// close the FTP connection
40
+
ftp_close($ftp);
40
41
?>
41
42
]]>
42
43
</programlisting>
43
44