cgi and multipart/form-data?

C

Chris Curvey

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?
 
C

Chris Curvey

Chris said:
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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,230
Messages
2,571,161
Members
47,796
Latest member
AlphonseNa

Latest Threads

Top