chdir
changes the directory. If you look at the underlying source, it doesn't return anything.
list
returns the list of files:
Returns an array of file information in the directory (the output is like
ls -l
). If a block is given, it iterates through the listing.
As a result files
will be nil, because chdir
didn't return anything. Instead you need to do something like:
ftp.chdir('forms/')
files = ftp.list
Look at Example #2 in the docs for an example, and ignore that they try to assign the result of chdir
.
nlist
would be even better than list
if all you want is the list of names. Use list
if you want a long-listing of the files so you can parse out permissions, sizes, etc.