Python ftplib - uploading multiple files?

ftplib, python

Solution

with the loop?

edit: in universal case uploading only files would look like this:

import os
for root, dirs, files in os.walk('path/to/local/dir'):
    for fname in files:
        full_fname = os.path.join(root, fname)
        ftp.storbinary('STOR remote/dir' + fname, open(full_fname, 'rb'))

Obviously, you need to look out for name collisions if you're just preserving file names like this.

Problem

I've googled but I could only find how to upload one file... and I'm trying to upload all files from local directory to remote ftp directory. Any ideas how to achieve this?

Original source