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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:35:02+00:00 2026-05-14T23:35:02+00:00

I wanted to design a simple site where one person can upload a file,

  • 0

I wanted to design a simple site where one person can upload a file, and pass off the random webaddress to someone, who can then download it.

At this point, I have a webpage where someone can successfully upload a file which gets stored under /files/ on my webserver.

The python script also generates a unique, random 5 letter code that gets stored in a database identifying the file

I have another page called retrieve, where a person should go, put in the 5 letter code, and it should pop up a filebox asking where to save the file.

My Problem is that: 1) How do I retrieve the file for download? At this point my retrieve script, takes the code, gets the location of the file on my server, but how do I get the brower to start downloading?

2)How do I stop people from directly going to the file? Should I change permissions on the file?

  • 1 1 Answer
  • 1 View
  • 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-05-14T23:35:03+00:00Added an answer on May 14, 2026 at 11:35 pm

    How do you serve the file-upload page, and how do you let your users upload files?
    If you are using Python’s built-in HTTP server modules you shouldn’t have any problems.
    Anyway, here’s how the file serving part is done using Python’s built-in modules (just the basic idea).

    Regarding your second question, if you were using these modules in the first place you probably wouldn’t have asked it because you’d have to explicitly serve specific files.

    import SocketServer
    import BaseHTTPServer
    
    
    class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    
        def do_GET(self):
            # The URL the client requested
            print self.path
    
            # analyze self.path, map the local file location...
    
            # open the file, load the data
            with open('test.py') as f: data = f.read()
    
            # send the headers
            self.send_response(200)
            self.send_header('Content-type', 'application/octet-stream') # you may change the content type
            self.end_headers()
            # If the file is not found, send error code 404 instead of 200 and display a message accordingly, as you wish.
    
            # wfile is a file-like object. writing data to it will send it to the client
            self.wfile.write(data)
    
            # XXX: Obviously, you might want to send the file in segments instead of loading it as a whole
    
    
    if __name__ == '__main__':
    
        PORT = 8080 # XXX
    
        try:
            server = SocketServer.ThreadingTCPServer(('', 8080), RequestHandler)
            server.serve_forever()
        except KeyboardInterrupt:
            server.socket.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a simple game design, and I wanted to break up my
I'm new to database design and just wanted a few opinions as to whether
Wanted to know if there was a way one could query shelveset details from
Wanted to know if someone had a suggestion on code or maybe there's a
I wanted to use 6 different textures on a cube, one per side, but
While working on a personal project I wanted a simple service to extract items
I am new to monotouch and wanted to know if there is a simple
I wanted to create a simple static jQuery based slider. Right now I just
Say you've got a very simple centred design, a 500px div centred in the
I have an HBase schema-design related question. The problem is fairly simple - I

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.