<p>The easiest way to describe how to send files is with a couple of examples:</p>
<pre>
<ftp server="ftp.apache.org"
userid="anonymous"
password="me@myorg.com">
<fileset dir="htdocs/manual"/>
</ftp>
</pre>
<p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
uploads all files in the <code>htdocs/manual</code> directory
to the default directory for that user.</p>
<pre><ftp server="ftp.apache.org"
remotedir="incoming"
userid="anonymous"
password="me@myorg.com"
depends="yes"
>
<fileset dir="htdocs/manual"/>
</ftp></pre>
<p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
uploads all new or changed files in the <code>htdocs/manual</code> directory
to the <code>incoming</code> directory relative to the default directory
for <code>anonymous</code>.</p>
<pre><ftp server="ftp.apache.org"
port="2121"
remotedir="/pub/incoming"
userid="coder"
password="java1"
depends="yes"
binary="no"
>
<fileset dir="htdocs/manual">
<include name="**/*.html"/>
</fileset>
</ftp></pre>
<p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as
<code>coder</code> with password <code>java1</code> and uploads all new or
changed HTML files in the <code>htdocs/manual</code> directory to the
<code>/pub/incoming</code> directory. The files are transferred in text mode. Passive mode has been switched on to send files from behind a firewall.</p>
<pre><ftp server="ftp.nt.org"
remotedir="c:\uploads"
userid="coder"
password="java1"
separator="\"
verbose="yes"</pre>
<PRE>
>
<fileset dir="htdocs/manual">
<include name="**/*.html"/>
</fileset>
</ftp></PRE><p>Logs in to the Windows-based <code>ftp.nt.org</code> as
<code>coder</code> with password <code>java1</code> and uploads all
HTML files in the <code>htdocs/manual</code> directory to the
<code>c:\uploads</code> directory. Progress messages are displayed as each
file is uploaded.</p>
<h3>Getting Files</h3>
<p>Getting files from an FTP server works pretty much the same way as
sending them does. The only difference is that the nested filesets
use the remotedir attribute as the base directory for the files on the
FTP server, and the dir attribute as the local directory to put the files
into. The file structure from the FTP site is preserved on the local machine.</p>
<pre>
<ftp action="get"
server="ftp.apache.org"
userid="anonymous"
password="me@myorg.com">
<fileset dir="htdocs/manual">
<include name="**/*.html"/>
</fileset>
</ftp>
</pre>
<p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
recursively downloads all .html files from default directory for that user
into the <code>htdocs/manual</code> directory on the local machine.</p>
<h3>Deleting Files</h3>
As you've probably guessed by now, you use nested fileset elements to
select the files to delete from the remote FTP server. Again, the
filesets are relative to the remote directory, not a local directory. In
fact, the dir attribute of the fileset is ignored completely.
<pre>
<ftp action="del"
server="ftp.apache.org"
userid="anonymous"
password="me@myorg.com">
<fileset>
<include name="**/*.tmp"/>
</fileset>
</ftp>
</pre>
<p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
tries to delete all *.tmp files from the default directory for that user.
If you don't have permission to delete a file, a BuildException is thrown.</p>