2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 07:05:15 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-12-22 00:43:04 +00:00
|
|
|
|
|
|
|
<chapter xml:id="ftp.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
|
|
&reftitle.examples;
|
|
|
|
<section xml:id="ftp.examples-basic">
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>FTP 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);
|
|
|
|
|
|
|
|
// check connection
|
|
|
|
if ((!$conn_id) || (!$login_result)) {
|
2010-01-17 19:56:37 +00:00
|
|
|
echo "FTP connection has failed!";
|
|
|
|
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
|
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
echo "Connected to $ftp_server, for user $ftp_user_name";
|
|
|
|
}
|
2007-12-22 00:43:04 +00:00
|
|
|
|
|
|
|
// upload the file
|
|
|
|
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
|
|
|
|
|
|
|
|
// check upload status
|
|
|
|
if (!$upload) {
|
2010-01-17 19:56:37 +00:00
|
|
|
echo "FTP upload has failed!";
|
|
|
|
} else {
|
|
|
|
echo "Uploaded $source_file to $ftp_server as $destination_file";
|
|
|
|
}
|
2007-12-22 00:43:04 +00:00
|
|
|
|
|
|
|
// close the FTP stream
|
|
|
|
ftp_close($conn_id);
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2007-12-22 00:43:04 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=xml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|
|
|
|
|
|
|
|
|