vincent Fri Dec 19 09:40:55 2003 EDT
Modified files:
/phpdoc/en/reference/ftp/functions ftp-chdir.xml ftp-chmod.xml
ftp-close.xml ftp-delete.xml
ftp-fget.xml ftp-fput.xml
ftp-get.xml ftp-login.xml
ftp-mdtm.xml ftp-mkdir.xml
ftp-nb-continue.xml
ftp-nb-fget.xml ftp-nb-fput.xml
ftp-nlist.xml ftp-pasv.xml
ftp-put.xml ftp-pwd.xml
ftp-rawlist.xml ftp-rename.xml
ftp-rmdir.xml ftp-set-option.xml
ftp-site.xml ftp-size.xml
ftp-ssl-connect.xml
ftp-systype.xml
Log:
Adding Examples and fixing a few
Index: phpdoc/en/reference/ftp/functions/ftp-chdir.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-chdir.xml:1.6
phpdoc/en/reference/ftp/functions/ftp-chdir.xml:1.7
--- phpdoc/en/reference/ftp/functions/ftp-chdir.xml:1.6 Sun Jun 29 11:05:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-chdir.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-chdir">
<refnamediv>
@@ -36,13 +36,17 @@
die("FTP connection has failed !");
}
-echo "Current directory : ", ftp_pwd($conn_id), "\n";
+echo "Current directory: " . ftp_pwd($conn_id) . "\n";
-if (@ftp_chdir($conn_id, "somedir")) {
- echo "Current directory is now : ", ftp_pwd($conn_id), "\n";
+// try to change the directory to somedir
+if (ftp_chdir($conn_id, "somedir")) {
+ echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
} else {
echo "Couldn't change directory\n";
}
+
+// close the connection
+ftp_close($conn_id);
?>
]]>
</programlisting>
Index: phpdoc/en/reference/ftp/functions/ftp-chmod.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-chmod.xml:1.2
phpdoc/en/reference/ftp/functions/ftp-chmod.xml:1.3
--- phpdoc/en/reference/ftp/functions/ftp-chmod.xml:1.2 Sun Jun 29 11:05:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-chmod.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<refentry id="function.ftp-chmod">
<refnamediv>
<refname>ftp_chmod</refname>
@@ -19,6 +19,34 @@
given as an <emphasis>octal</emphasis> value.
</para>
<para>
+ <example>
+ <title><function>ftp_chmod</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$file = 'public_html/index.php';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// try to chmod $file to 644
+if (ftp_chmod($conn_id, 0644, $file)) {
+ echo "$file cdmoded successfully to 644\n";
+} else {
+ echo "could not chmod $file\n";
+}
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
Returns the new file permissions on success or &false; on error.
</para>
<para>
Index: phpdoc/en/reference/ftp/functions/ftp-close.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-close.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-close.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-close.xml:1.4 Fri Nov 8 05:09:00 2002
+++ phpdoc/en/reference/ftp/functions/ftp-close.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.34 -->
<refentry id="function.ftp-close">
<refnamediv>
@@ -18,6 +18,29 @@
you can no longer use the FTP connection and must create a new one
with <function>ftp_connect</function>.
</simpara>
+ <para>
+ <example>
+ <title><function>ftp_close</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// print the current directory
+echo ftp_pwd($conn_id); // /
+
+// close this connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<simpara>
See also <function>ftp_connect</function>
</simpara>
Index: phpdoc/en/reference/ftp/functions/ftp-delete.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-delete.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-delete.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-delete.xml:1.4 Tue Nov 12 06:57:54
2002
+++ phpdoc/en/reference/ftp/functions/ftp-delete.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-delete">
<refnamediv>
@@ -18,6 +18,34 @@
<parameter>path</parameter> from the FTP server.
</para>
<para>
+ <example>
+ <title><function>ftp_delete</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$file = 'public_html/old.txt';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// try to delete $file
+if (ftp_delete($conn_id, $file)) {
+ echo "$file deleted successful\n";
+} else {
+ echo "could not delete $file\n";
+}
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
&return.success;
</para>
</refsect1>
Index: phpdoc/en/reference/ftp/functions/ftp-fget.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-fget.xml:1.7
phpdoc/en/reference/ftp/functions/ftp-fget.xml:1.8
--- phpdoc/en/reference/ftp/functions/ftp-fget.xml:1.7 Sun Jun 29 11:05:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-fget.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-fget">
<refnamediv>
@@ -23,6 +23,38 @@
specified must be either <constant>FTP_ASCII</constant> or
<constant>FTP_BINARY</constant>.
</para>
+ <para>
+ <example>
+ <title><function>ftp_fget</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// open some file for reading
+$file = 'somefile.txt';
+$fp = fopen($file, 'w');
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// try to download $file
+if (ftp_fget($conn_id, $fp, $file, FTP_ASCII, 1)) {
+ echo "successfully written to $file\n";
+} else {
+ echo "There was a problem with $file\n";
+}
+
+// close the connection and the file handler
+ftp_close($conn_id);
+fclose($fp);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<note>
<para>
The <parameter>resumepos</parameter> parameter was added in PHP 4.3.0.
Index: phpdoc/en/reference/ftp/functions/ftp-fput.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.9
phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.10
--- phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.9 Mon Dec 15 11:49:47 2003
+++ phpdoc/en/reference/ftp/functions/ftp-fput.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-fput">
<refnamediv>
@@ -34,18 +34,20 @@
$file = 'somefile.txt';
$fp = fopen($file, 'r');
-// connect to the server
+// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
-// try to upload the file
+// try to upload $file
if (ftp_fput($conn_id, $file, $fp, FTP_ASCII)) {
echo "Successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
-// close the connection and the file handler
+// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);
Index: phpdoc/en/reference/ftp/functions/ftp-get.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-get.xml:1.7
phpdoc/en/reference/ftp/functions/ftp-get.xml:1.8
--- phpdoc/en/reference/ftp/functions/ftp-get.xml:1.7 Sun Aug 17 09:14:23 2003
+++ phpdoc/en/reference/ftp/functions/ftp-get.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-get">
<refnamediv>
@@ -42,11 +42,13 @@
$local_file = 'local.zip';
$server_file = 'server.zip';
-// connect to the FTP server
+// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
-// try to download
+// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
Index: phpdoc/en/reference/ftp/functions/ftp-login.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-login.xml:1.5
phpdoc/en/reference/ftp/functions/ftp-login.xml:1.6
--- phpdoc/en/reference/ftp/functions/ftp-login.xml:1.5 Thu May 29 10:49:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-login.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-login">
<refnamediv>
@@ -39,7 +39,9 @@
} else {
echo "Couldn't connect as $ftp_user\n";
}
-
+
+// close the connection
+ftp_close($conn_id);
?>
]]>
</programlisting>
Index: phpdoc/en/reference/ftp/functions/ftp-mdtm.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.6
phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.7
--- phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.6 Thu Dec 18 12:44:04 2003
+++ phpdoc/en/reference/ftp/functions/ftp-mdtm.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-mdtm">
<refnamediv>
@@ -30,8 +30,10 @@
$file = 'somefile.txt';
-// connect to the server
+// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// get the last modified time
Index: phpdoc/en/reference/ftp/functions/ftp-mkdir.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-mkdir.xml:1.5
phpdoc/en/reference/ftp/functions/ftp-mkdir.xml:1.6
--- phpdoc/en/reference/ftp/functions/ftp-mkdir.xml:1.5 Sun Jun 29 11:05:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-mkdir.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-mkdir">
<refnamediv>
@@ -20,6 +20,35 @@
Returns the newly created directory name on success or &false; on error.
</para>
<para>
+ <example>
+ <title><function>ftp_mkdir</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$dir = 'www';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// try to create the directory $dir
+if (ftp_mkdir($conn_id, $dir)) {
+ echo "successfully created $dir\n";
+} else {
+ echo "There was a problem while creating $dir\n";
+}
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
See also <function>ftp_rmdir</function>.
</para>
</refsect1>
Index: phpdoc/en/reference/ftp/functions/ftp-nb-continue.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-nb-continue.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-nb-continue.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-nb-continue.xml:1.4 Sun Sep 14 20:41:58
2003
+++ phpdoc/en/reference/ftp/functions/ftp-nb-continue.xml Fri Dec 19 09:40:54
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="function.ftp-nb-continue">
<refnamediv>
<refname>ftp_nb_continue</refname>
@@ -15,6 +15,29 @@
Continues retrieving/sending a file non-blocking.
</para>
<para>
+ <example>
+ <title><function>ftp_nb_continue</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// Initate the download
+$ret = ftp_nb_get($my_connection, "test", "README", FTP_BINARY);
+while ($ret == FTP_MOREDATA) {
+
+ // Continue downloading...
+ $ret = ftp_nb_continue($my_connection);
+}
+if ($ret != FTP_FINISHED) {
+ echo "There was an error downloading the file...";
+ exit(1);
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
Returns <constant>FTP_FAILED</constant> or <constant>FTP_FINISHED</constant>
or <constant>FTP_MOREDATA</constant>.
</para>
Index: phpdoc/en/reference/ftp/functions/ftp-nb-fget.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-nb-fget.xml:1.6
phpdoc/en/reference/ftp/functions/ftp-nb-fget.xml:1.7
--- phpdoc/en/reference/ftp/functions/ftp-nb-fget.xml:1.6 Sun Sep 14 20:41:59
2003
+++ phpdoc/en/reference/ftp/functions/ftp-nb-fget.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<refentry id="function.ftp-nb-fget">
<refnamediv>
<refname>ftp_nb_fget</refname>
@@ -19,13 +19,50 @@
<function>ftp_nb_fget</function> retrieves <parameter>remote_file</parameter>
from the FTP server, and writes it to the given file pointer,
<parameter>handle</parameter>. The transfer <parameter>mode</parameter>
- specified must be either <constant>FTP_ASCII</constant> or
+ specified must be either <constant>FTP_ASCII</constant> or
<constant>FTP_BINARY</constant>. The difference between this function and the
<function>ftp_fget</function> is that this function retrieves the file
asynchronously, so your program can perform other operations while the
file is being downloaded.
</para>
<para>
+ <example>
+ <title><function>ftp_nb_fget</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// open some file for reading
+$file = 'index.php';
+$fp = fopen($file, 'w');
+
+$conn_id = ftp_connect($ftp_server);
+
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// Initate the download
+$ret = ftp_nb_fget($conn_id, $fp, $file, FTP_BINARY);
+while ($ret == FTP_MOREDATA) {
+
+ // Do whatever you want
+ echo ".";
+
+ // Continue downloading...
+ $ret = ftp_nb_continue($conn_id);
+}
+if ($ret != FTP_FINISHED) {
+ echo "There was an error downloading the file...";
+ exit(1);
+}
+
+// close filepointer
+fclose($fp);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
Returns <constant>FTP_FAILED</constant>, <constant>FTP_FINISHED</constant>, or
<constant>FTP_MOREDATA</constant>.
</para>
Index: phpdoc/en/reference/ftp/functions/ftp-nb-fput.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-nb-fput.xml:1.7
phpdoc/en/reference/ftp/functions/ftp-nb-fput.xml:1.8
--- phpdoc/en/reference/ftp/functions/ftp-nb-fput.xml:1.7 Sun Sep 14 20:41:59
2003
+++ phpdoc/en/reference/ftp/functions/ftp-nb-fput.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<refentry id="function.ftp-nb-fput">
<refnamediv>
<refname>ftp_nb_fput</refname>
@@ -26,6 +26,42 @@
perform other operations while the file is being uploaded.
</para>
<para>
+ <example>
+ <title><function>ftp_nb_fput</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$file = 'index.php';
+
+$fp = fopen($file, 'r');
+
+$conn_id = ftp_connect($ftp_server);
+
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// Initate the upload
+$ret = ftp_nb_fput($conn_id, $file, $fp, FTP_BINARY);
+while ($ret == FTP_MOREDATA) {
+
+ // Do whatever you want
+ echo ".";
+
+ // Continue upload...
+ $ret = ftp_nb_continue($conn_id);
+}
+if ($ret != FTP_FINISHED) {
+ echo "There was an error uploading the file...";
+ exit(1);
+}
+
+fclose($fp);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
Returns <constant>FTP_FAILED</constant>, <constant>FTP_FINISHED</constant>, or
<constant>FTP_MOREDATA</constant>.
</para>
Index: phpdoc/en/reference/ftp/functions/ftp-nlist.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-nlist.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-nlist.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-nlist.xml:1.4 Thu May 29 10:49:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-nlist.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-nlist">
<refnamediv>
@@ -25,24 +25,33 @@
// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
-// check connection
-if ((!$conn_id) || (!$login_result)) {
- die("FTP connection has failed !");
-}
-
-// get contents of the root directory
-$contents = ftp_nlist($conn_id, "/");
-
-// print each entry
-foreach ($contents as $entry) {
- echo $entry, "<br />\n";
-}
+// get contents of the current directory
+$contents = ftp_nlist($conn_id, ".");
+
+// output $contents
+var_dump($contents);
?>
]]>
</programlisting>
+ <para>
+� � The above example will output something similar to:
+ </para>
+ <screen>
+<![CDATA[
+array(3) {
+ [0]=>
+ string(11) "public_html"
+ [1]=>
+ string(10) "public_ftp"
+ [2]=>
+ string(3) "www"
+]]>
+� � </screen>
</example>
<para>
See also <function>ftp_rawlist</function>.
Index: phpdoc/en/reference/ftp/functions/ftp-pasv.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-pasv.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-pasv.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-pasv.xml:1.4 Tue Nov 12 06:57:54 2002
+++ phpdoc/en/reference/ftp/functions/ftp-pasv.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-pasv">
<refnamediv>
@@ -21,6 +21,38 @@
rather than by the server.
</para>
<para>
+ <example>
+ <title><function>ftp_pasv</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$file = 'somefile.txt';
+$remote_file = 'readme.txt';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// turn passive mode on
+ftp_pasv($conn_id, true);
+
+// upload a file
+if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
+ echo "successfully uploaded $file\n";
+} else {
+ echo "There was a problem while uploading $file\n";
+}
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
&return.success;
</para>
</refsect1>
Index: phpdoc/en/reference/ftp/functions/ftp-put.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-put.xml:1.6
phpdoc/en/reference/ftp/functions/ftp-put.xml:1.7
--- phpdoc/en/reference/ftp/functions/ftp-put.xml:1.6 Sun Jun 29 11:05:37 2003
+++ phpdoc/en/reference/ftp/functions/ftp-put.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-put">
<refnamediv>
@@ -36,7 +36,24 @@
<programlisting role="php">
<![CDATA[
<?php
-$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII);
+$file = 'somefile.txt';
+$remote_file = 'readme.txt';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// upload a file
+if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
+ echo "successfully uploaded $file\n";
+} else {
+ echo "There was a problem while uploading $file\n";
+}
+
+// close the connection
+ftp_close($conn_id);
?>
]]>
</programlisting>
Index: phpdoc/en/reference/ftp/functions/ftp-pwd.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-pwd.xml:1.3
phpdoc/en/reference/ftp/functions/ftp-pwd.xml:1.4
--- phpdoc/en/reference/ftp/functions/ftp-pwd.xml:1.3 Tue Sep 17 05:46:58 2002
+++ phpdoc/en/reference/ftp/functions/ftp-pwd.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-pwd">
<refnamediv>
@@ -15,6 +15,32 @@
<para>
Returns the current directory or &false; on error.
</para>
+ <para>
+ <example>
+ <title><function>ftp_pwd</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// change directory to public_html
+ftp_chdir($conn_id, 'public_html');
+
+// print current directory
+echo ftp_pwd($conn_id); // /public_html
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</refsect1>
</refentry>
Index: phpdoc/en/reference/ftp/functions/ftp-rawlist.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-rawlist.xml:1.3
phpdoc/en/reference/ftp/functions/ftp-rawlist.xml:1.4
--- phpdoc/en/reference/ftp/functions/ftp-rawlist.xml:1.3 Thu May 29 10:49:37
2003
+++ phpdoc/en/reference/ftp/functions/ftp-rawlist.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-rawlist">
<refnamediv>
@@ -21,6 +21,47 @@
can be used to determine how the results should be interpreted.
</para>
<para>
+ <example>
+ <title><function>ftp_rawlist</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// get the file list for /
+$buff = ftp_rawlist($conn_id, '/');
+
+// close the connection
+ftp_close($conn_id);
+
+// output the buffer
+var_dump($buff);
+?>
+]]>
+ </programlisting>
+ <para>
+� � The above example will output something similar to:
+� � </para>
+ <screen>
+<![CDATA[
+array(3) {
+ [0]=>
+ string(65) "drwxr-x--- 3 vincent vincent 4096 Jul 12 12:16 public_ftp"
+ [1]=>
+ string(66) "drwxr-x--- 15 vincent vincent 4096 Nov 3 21:31 public_html"
+ [2]=>
+ string(73) "lrwxrwxrwx 1 vincent vincent 11 Jul 12 12:16 www ->
public_html"
+}
+]]>
+� � </screen>
+ </example>
+ </para>
+ <para>
See also <function>ftp_nlist</function>.
</para>
</refsect1>
Index: phpdoc/en/reference/ftp/functions/ftp-rename.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-rename.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-rename.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-rename.xml:1.4 Tue Nov 12 06:57:54
2002
+++ phpdoc/en/reference/ftp/functions/ftp-rename.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-rename">
<refnamediv>
@@ -21,6 +21,35 @@
<parameter>ftp_stream</parameter>.
</para>
<para>
+ <example>
+ <title><function>ftp_rename</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_file = 'somefile.txt.bak';
+$new_file = 'somefile.txt';
+
+// set up basic connection
+$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+// try to rename $olf_file to $new_file
+if (ftp_rename($conn_id, $old_file, $new_file)) {
+ echo "successfully renamed $old_file to $new_file\n";
+} else {
+ echo "There was a problem while renaming $old_file to $new_file\n";
+}
+
+// close the connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
&return.success;
</para>
</refsect1>
Index: phpdoc/en/reference/ftp/functions/ftp-rmdir.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.6
phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.7
--- phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.6 Sun Aug 17 09:14:23 2003
+++ phpdoc/en/reference/ftp/functions/ftp-rmdir.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-rmdir">
<refnamediv>
@@ -30,13 +30,17 @@
$dir = 'www/';
+// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+// try to delete the directory $dir
if (ftp_rmdir($conn_id, $dir)) {
- echo 'Successfully deleted ' . $dir;
+ echo "Successfully deleted $dir\n";
} else {
- echo 'There was a problem while deleting ' . $dir;
+ echo "There was a problem while deleting $dir\n";
}
ftp_close($conn_id);
Index: phpdoc/en/reference/ftp/functions/ftp-set-option.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-set-option.xml:1.7
phpdoc/en/reference/ftp/functions/ftp-set-option.xml:1.8
--- phpdoc/en/reference/ftp/functions/ftp-set-option.xml:1.7 Sun Jun 1 15:26:30
2003
+++ phpdoc/en/reference/ftp/functions/ftp-set-option.xml Fri Dec 19 09:40:54
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.32 -->
<refentry id='function.ftp-set-option'>
<refnamediv>
@@ -47,17 +47,19 @@
</tgroup>
</table>
</para>
- <example>
- <title><function>ftp_set_option</function> example</title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title><function>ftp_set_option</function> example</title>
+ <programlisting role="php">
<![CDATA[
<?php
// Set the network timeout to 10 seconds
ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 10);
?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
<para>
See also <function>ftp_get_option</function>.
</para>
Index: phpdoc/en/reference/ftp/functions/ftp-site.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-site.xml:1.5
phpdoc/en/reference/ftp/functions/ftp-site.xml:1.6
--- phpdoc/en/reference/ftp/functions/ftp-site.xml:1.5 Tue Aug 12 17:28:58 2003
+++ phpdoc/en/reference/ftp/functions/ftp-site.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.3 -->
<refentry id="function.ftp-site">
<refnamediv>
@@ -20,9 +20,10 @@
useful for handling such things as file permissions and group
membership.
</para>
- <example>
- <title>Sending a SITE command to an ftp server</title>
- <programlisting role="php">
+ <para>
+ <example>
+ <title>Sending a SITE command to an ftp server</title>
+ <programlisting role="php">
<![CDATA[
<?php
/* Connect to FTP server */
@@ -40,8 +41,9 @@
}
?>
]]>
- </programlisting>
- </example>
+ </programlisting>
+ </example>
+ </para>
<para>
&return.success;
</para>
Index: phpdoc/en/reference/ftp/functions/ftp-size.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-size.xml:1.4
phpdoc/en/reference/ftp/functions/ftp-size.xml:1.5
--- phpdoc/en/reference/ftp/functions/ftp-size.xml:1.4 Sun Aug 17 09:14:23 2003
+++ phpdoc/en/reference/ftp/functions/ftp-size.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-size">
<refnamediv>
@@ -31,10 +31,13 @@
$file = 'somefile.txt';
-// connect to the server
+// set up basic connection
$conn_id = ftp_connect($ftp_server);
+
+// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+// get the size of $file
$res = ftp_size($conn_id, $file);
if ($res != -1) {
@@ -43,6 +46,7 @@
echo "couldn't get the size";
}
+// close the connection
ftp_close($conn_id);
?>
Index: phpdoc/en/reference/ftp/functions/ftp-ssl-connect.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-ssl-connect.xml:1.3
phpdoc/en/reference/ftp/functions/ftp-ssl-connect.xml:1.4
--- phpdoc/en/reference/ftp/functions/ftp-ssl-connect.xml:1.3 Sun Jun 29 11:05:37
2003
+++ phpdoc/en/reference/ftp/functions/ftp-ssl-connect.xml Fri Dec 19 09:40:54
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-ssl-connect">
<refnamediv>
@@ -30,6 +30,28 @@
<function>ftp_set_option</function> and
<function>ftp_get_option</function>.
</para>
+ <para>
+ <example>
+ <title><function>ftp_ssl_connect</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// set up basic ssl connection
+$conn_id = ftp_ssl_connect($ftp_server);
+
+// login with username and password
+$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
+
+echo ftp_pwd($conn_id); // /
+
+// close the ssl connection
+ftp_close($conn_id);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<note>
<title>Why this function may not exist</title>
<para>
Index: phpdoc/en/reference/ftp/functions/ftp-systype.xml
diff -u phpdoc/en/reference/ftp/functions/ftp-systype.xml:1.3
phpdoc/en/reference/ftp/functions/ftp-systype.xml:1.4
--- phpdoc/en/reference/ftp/functions/ftp-systype.xml:1.3 Sat Aug 16 05:12:31
2003
+++ phpdoc/en/reference/ftp/functions/ftp-systype.xml Fri Dec 19 09:40:54 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/ftp.xml, last change in rev 1.2 -->
<refentry id="function.ftp-systype">
<refnamediv>
@@ -37,7 +37,7 @@
]]>
</programlisting>
<para>
- This example will produce
+ The above example will output something similar to:
</para>
<screen>
<![CDATA[