By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

cgi and multipart/form-data?

P: n/a
I have a form like this:

<form method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="text" name="foo">
<input type="submit">
</form>

When I submit this form to my Python script using the CGI module, I seem
to get the "myFile" variable, but I don't seem to the "foo" variable.

Interestingly, if I take out the "myFile" variable (or specify a much
smaller file) I do get the value for "foo".

The files that I'm trying to handle are 400-500Kb in size...is there
something I need to do (cgi.maxlen?) to let cgi handle big files?
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Chris Curvey wrote:
I have a form like this:

<form method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="text" name="foo">
<input type="submit">
</form>

When I submit this form to my Python script using the CGI module, I seem
to get the "myFile" variable, but I don't seem to the "foo" variable.

Interestingly, if I take out the "myFile" variable (or specify a much
smaller file) I do get the value for "foo".

The files that I'm trying to handle are 400-500Kb in size...is there
something I need to do (cgi.maxlen?) to let cgi handle big files?


man, was I on the wrong track. turns out the problem was that I was
uploading a Excel file and something in there was getting thought of as
an end-of-file marker. To fix:

import msvcrt
msvcrt.setmode(0, os.O_BINARY) # stdin = 0
msvcrt.setmode(1, os.O_BINARY) # stdout = 1

(credit where it's due: I found this on ASPN.)
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.