Nov-02-2018, 01:38 PM
I have some folder and subfolder and files in my computer like this:
and i want to upload this folders and files in my serveur ftp.
I have a code but is wrong because my folder go to the server ftp like that:
here is the code
![[Image: architectureDossier.png]](https://www.scenographie-vr.com/media/telechargement/architectureDossier.png)
and i want to upload this folders and files in my serveur ftp.
I have a code but is wrong because my folder go to the server ftp like that:
![[Image: dossierSurFtp.png]](https://www.scenographie-vr.com/media/telechargement/dossierSurFtp.png)
here is the code
import ftplib import os server = 'localhost' username = 'generic_user' password = 'password' myFTP = ftplib.FTP(server, username, password) myPath = r'/Users/olivier/Documents/essai' def uploadThis(path): files = os.listdir(path) os.chdir(path) for f in files: if os.path.isfile(f): fh = open(f, 'rb') myFTP.storbinary('STOR %s' % f, fh) fh.close() elif os.path.isdir(f): myFTP.mkd(f) myFTP.cwd(f) uploadThis(f) myFTP.cwd('..') os.chdir('..') uploadThis(myPath)