[ACCEPTED]-Python ftplib - uploading multiple files?-ftplib

Accepted answer
Score: 16

with the loop?

edit: in universal case uploading 3 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 2 need to look out for name collisions if 1 you're just preserving file names like this.

Score: 0

Look at Python-scriptlines required to make upload-files from JSON-Call and next FTPlib-operation: why some uploads, but others not?

Although a different starting 9 position than your question, in the Answer of 8 that first url you see an example construction 7 to upload by ftplib a json-file plus an 6 xml-file: look at scriptline 024 and further.

In 5 the second url you see some other aspects 4 related to upload of more files.

Also applicable 3 for other file-types than json and xml, obviously 2 with a different 'entry' before the 2 final 1 sections which define and realize the FTP_Upload-function.

More Related questions