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 9161203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:54:56+00:00 2026-06-17T13:54:56+00:00

I need to upload a file to a remote location using python – wsgi.

  • 0

I need to upload a file to a remote location using python – wsgi.
Remote location means not the server which host the python application, it is a different server.

I tried upload a file to the server which exactly the application host. And it is succeeded.

using following code,

            post = cgi.FieldStorage(fp=environ['wsgi.input'],environ=environ,keep_blank_values=True)
        self.msg = str(post)            

        try:
            fileitem = post['Filedata']
            if fileitem.file:
                filename = fileitem.filename.decode('utf8').replace('\\','/').split('/')[-1].strip()
                if not filename:
                    raise Exception('No valid filename specified')
                file_path = os.path.join(self.uploadpath, filename)
                # Using with makes Python automatically close the file for you
                counter = 0
                with open(file_path, 'wb') as output_file:
                    while 1:
                        data = fileitem.file.read(1024)
                        # End of file
                        if not data:
                            break
                        output_file.write(data)
                        counter += 1
                        if counter == 100:
                            counter = 0
            self.msg = "Uploaded Successfully !!!! "
        except:
            pass

But this is for the the local location which the python application hosted.
I search about Google how to upload a file to remote location in python.
But I can’t find a proper solution for that. Some are suggested to do scp from python code.

more..

Let say there are two servers called A and B. My python-wsgi application for file uploading is hosted on server A. In the python-wsgi application there is a web form to select the file by user when user click upload then that file need to uploaded to server B (known location)

Any one knows a way or library to upload a file to remote location using python?

Thanks in advance.

  • 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-17T13:54:58+00:00Added an answer on June 17, 2026 at 1:54 pm

    For HTTP, you won’t have any chance to put a file on the server without an adequate counterpart on the server-side, i.e., a Python / Perl / PHP / Ruby / whatever script that takes the data you provide in a HTTP POST – request and writes them to a file. I’d recommend setting up an FTP-server. That’s exactly what FTP was invented for.

    Usually, most HTTP servers have FTP as well. How do you put your HTML-files on the server? FTP is kind-of minimal access needed to do so. It’s really not hard to set up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to update a file which is on a remote server, using Silverlight
In my project I need to upload a big file (~250GB) to remote server,
I need to upload a file in C# using an httpwebrequest. I don't need
I need to upload .dat file from jsp page. I am using struts. I
I'm writing GWT application where I need to upload video file and encode that
i am developing register form using php where i need to upload the file
Inside a grails application, I need to upload a file under web-app/js, add a
I need to upload a xml file from server side, where the contents of
I need to upload my app file through Application Loader 2.7. But first I
I need to upload a csv file to a server. works fine for smaller

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.