Jump to content

Form upload file to Python webserver?


Dave-ee Jones
 Share

Recommended Posts

Hoi!

So I'm trying to upload a file using a HTML form..

<input class="form-control" id="file" name="file" type="file"/>

And then save it to a file using my Python webserver (standard TCP SimpleHTTPServer). However, I'm not sure how I would do this because the form also has other inputs in it (checkboxes, text boxes etc.) and therefore am not sure how I would go about it.

I'm using the CGI method to grab the variables from the POST:

LENGTH = int(self.headers["Content-length"])
VARIABLES = cgi.parse_qs(self.rfile.read(LENGTH),keep_blank_values=1)

And I get a list of the form objects' names and their values, except I'm not sure how to handle the file's one.

Has anyone got an idea of how to go about this? Am stuck, so any help is appreciated! :)

Any alternatives to this would be considered too, as I'm not very happy with this mucky way of doing this..

Edited by Dave-ee Jones
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...