Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7976601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:57:01+00:00 2026-06-04T08:57:01+00:00

I was using pycurl to transfer files over ftp in python. I could create

  • 0

I was using pycurl to transfer files over ftp in python. I could create the missing directories automatically on my remote server using:

c.setopt(pycurl.FTP_CREATE_MISSING_DIRS, 1)

for some reasons, I have to switch to ftplib. But I don’t know how to to the same here. Is there any option to add to storbinary function to do that? or I have to create the directories manually?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:57:03+00:00Added an answer on June 4, 2026 at 8:57 am

    FTP_CREATE_MISSING_DIRS is a curl operation (added here). I’d hazard a guess that you have to do it manually with ftplib, but I’d love to be proven wrong, anyone?

    I’d do something like the following: (untested, and need to catch ftplib.all_errors)

    ftp = ... # Create connection
    
    # Change directories - create if it doesn't exist
    def chdir(dir): 
        if directory_exists(dir) is False: # (or negate, whatever you prefer for readability)
            ftp.mkd(dir)
        ftp.cwd(dir)
    
    # Check if directory exists (in current location)
    def directory_exists(dir):
        filelist = []
        ftp.retrlines('LIST',filelist.append)
        for f in filelist:
            if f.split()[-1] == dir and f.upper().startswith('D'):
                return True
        return False
    

    Or you could do directory_exists like this: (a bit harder to read?)

    # Check if directory exists (in current location)
    def directory_exists(dir):
        filelist = []
        ftp.retrlines('LIST',filelist.append)
        return any(f.split()[-1] == dir and f.upper().startswith('D') for f in filelist)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create FTP-uploader, i am using pycurl and python, but i dont
I'm using pycurl to upload a file via put and python cgi script to
Here is the working code in Python (using cURL): #!/usr/bin/python import pycurl c =
I'm trying to download multiple images concurrently using Python over the internet, and I've
I'm writing a simple program in Python 2.7 using pycURL library to submit file
Does Python have screen scraping libraries that offer JavaScript support? I've been using pycurl
I'm running Python 2.6.4 on Mac Snow Leopard. I installed pycurl using: sudo env
I am using Python 2.5 on Windows 7 (64bit). I installed pycurl-7.15.5.1 (with win
I am a beginner using Python and Pycurl for webpage stressing testing purposes. However,
Using boost python I need create nested namespace. Assume I have following cpp class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.