cvs: phpdoc /en/reference/ftp/functions ftp-exec.xml ftp-fput.xml ftp-get.xml ftp-mdtm.xml ftp-rmdir.xml ftp-size.xml

From: Date: Sun, 17 Aug 2003 13:14:23 +0000
Subject: cvs: phpdoc /en/reference/ftp/functions ftp-exec.xml ftp-fput.xml ftp-get.xml ftp-mdtm.xml ftp-rmdir.xml ftp-size.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969355874@lists.php.net to get a copy of this message
didou Sun Aug 17 09:14:23 2003 EDT Modified files: /phpdoc/en/reference/ftp/functions ftp-exec.xml ftp-fput.xml ftp-get.xml ftp-mdtm.xml ftp-rmdir.xml ftp-size.xml Log: adding examples proposed by vincent at php dot net

Index: phpdoc/en/reference/ftp/functions/ftp-exec.xml diff -u phpdoc/en/reference/ftp/functions/ftp-exec.xml:1.7 phpdoc/en/reference/ftp/functions/ftp-exec.xml:1.8 --- phpdoc/en/reference/ftp/functions/ftp-exec.xml:1.7 Sun Jun 29 11:05:37 2003 +++ phpdoc/en/reference/ftp/functions/ftp-exec.xml Sun Aug 17 09:14:22 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-exec'> <refnamediv> @@ -17,6 +17,31 @@ Sends a SITE EXEC <parameter>command</parameter> request to the FTP server. Returns &true; if the command was successful (server sent response code: <literal>200</literal>); otherwise returns &false;. + </para> + <para> + <example> + <title><function>ftp_exec</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$command = 'ls -al'; + +$conn_id = ftp_connect($ftp_server); + +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +if($res = ftp_exec($conn_id, $command)) { + echo "$command executed successfully<br />\n"; + echo nl2br($res); +} else { + echo 'could not execute ' . $command; +} + +?> +]]> + </programlisting> + </example> </para> <para> See also <function>ftp_raw</function>. Index: phpdoc/en/reference/ftp/functions/ftp-fput.xml diff -u phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.7 phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.8 --- phpdoc/en/reference/ftp/functions/ftp-fput.xml:1.7 Sun Jun 29 11:05:37 2003 +++ phpdoc/en/reference/ftp/functions/ftp-fput.xml Sun Aug 17 09:14:23 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-fput"> <refnamediv> @@ -22,6 +22,37 @@ in <parameter>remote_file</parameter> on the FTP server. The transfer <parameter>mode</parameter> specified must be either <constant>FTP_ASCII</constant> or <constant>FTP_BINARY</constant>. + </para> + <para> + <example> + <title><function>ftp_fput</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// open some file for reading +$file = 'somefile.txt'; +$fp = fopen($file, 'r'); + +// connect to the server +$conn_id = ftp_connect($ftp_server); +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +// try to upload the 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 +ftp_close($conn_id); +fclose($fp); + +?> +]]> + </programlisting> + </example> </para> <note> <para> Index: phpdoc/en/reference/ftp/functions/ftp-get.xml diff -u phpdoc/en/reference/ftp/functions/ftp-get.xml:1.6 phpdoc/en/reference/ftp/functions/ftp-get.xml:1.7 --- phpdoc/en/reference/ftp/functions/ftp-get.xml:1.6 Sun Jun 29 11:05:37 2003 +++ phpdoc/en/reference/ftp/functions/ftp-get.xml Sun Aug 17 09:14:23 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-get"> <refnamediv> @@ -30,6 +30,36 @@ </note> <para> &return.success; + </para> + <para> + <example> + <title><function>ftp_get</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +// define some variables +$local_file = 'local.zip'; +$server_file = 'server.zip'; + +// connect to the FTP server +$conn_id = ftp_connect($ftp_server); +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +// try to download +if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { + echo "Successfully written to $local_file\n"; +} else { + echo "There was a problem\n"; +} + +// close the connection +ftp_close($conn_id); + +?> +]]> + </programlisting> + </example> </para> <para> See also <function>ftp_fget</function>, <function>ftp_nb_get</function> and Index: phpdoc/en/reference/ftp/functions/ftp-mdtm.xml diff -u phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.3 phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.4 --- phpdoc/en/reference/ftp/functions/ftp-mdtm.xml:1.3 Tue Sep 17 05:46:57 2002 +++ phpdoc/en/reference/ftp/functions/ftp-mdtm.xml Sun Aug 17 09:14:23 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-mdtm"> <refnamediv> @@ -21,6 +21,37 @@ <para> Returns a UNIX timestamp on success, or -1 on error. </para> +<para> + <example> + <title></title> + <programlisting role="php"> +<![CDATA[ +<?php + +$file = 'somefile.txt'; + +// connect to the server +$conn_id = ftp_connect($ftp_server); +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +// get the last modified time +$buff = ftp_mdtm($conn_id, $file); + +if ($buff != -1) { + // somefile.txt was last modified on: March 26 2003 14:16:41. + echo "$file was last modified on : " . date ("F d Y H:i:s.", $buff); +} else { + echo "Couldn't get mdtime"; +} + +// close the connection +ftp_close($conn_id); + +?> +]]> + </programlisting> + </example> +</para> <note> <para> Not all servers support this feature! Index: phpdoc/en/reference/ftp/functions/ftp-rmdir.xml diff -u phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.5 phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.6 --- phpdoc/en/reference/ftp/functions/ftp-rmdir.xml:1.5 Thu May 29 10:49:37 2003 +++ phpdoc/en/reference/ftp/functions/ftp-rmdir.xml Sun Aug 17 09:14:23 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-rmdir"> <refnamediv> @@ -20,6 +20,31 @@ </para> <para> &return.success; + </para> + <para> + <example> + <title><function>ftp_rmdir</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$dir = 'www/'; + +$conn_id = ftp_connect($ftp_server); +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +if (ftp_rmdir($conn_id, $dir)) { + echo 'Successfully deleted ' . $dir; +} else { + echo 'There was a problem while deleting ' . $dir; +} + +ftp_close($conn_id); + +?> +]]> + </programlisting> + </example> </para> <para> See also <function>ftp_mkdir</function>. Index: phpdoc/en/reference/ftp/functions/ftp-size.xml diff -u phpdoc/en/reference/ftp/functions/ftp-size.xml:1.3 phpdoc/en/reference/ftp/functions/ftp-size.xml:1.4 --- phpdoc/en/reference/ftp/functions/ftp-size.xml:1.3 Thu May 29 10:49:37 2003 +++ phpdoc/en/reference/ftp/functions/ftp-size.xml Sun Aug 17 09:14:23 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-size"> <refnamediv> @@ -21,6 +21,34 @@ </para> <para> Returns the file size on success, or -1 on error. + </para> + <para> + <example> + <title><function>ftp_size</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$file = 'somefile.txt'; + +// connect to the server +$conn_id = ftp_connect($ftp_server); +$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); + +$res = ftp_size($conn_id, $file); + +if ($res != -1) { + echo "size of $file is $res bytes"; +} else { + echo "couldn't get the size"; +} + +ftp_close($conn_id); + +?> +]]> + </programlisting> + </example> </para> <para> See also <function>ftp_rawlist</function>.
« previous php.doc (#969355874) next »