Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > cgi and multipart/form-data?

Reply
Thread Tools

cgi and multipart/form-data?

 
 
Chris Curvey
Guest
Posts: n/a
 
      03-29-2005
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?
 
Reply With Quote
 
 
 
 
Chris Curvey
Guest
Posts: n/a
 
      03-29-2005
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.)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(CGI-Target)Could not connect to CGI-Proxy John Smith Java 0 05-15-2006 09:21 PM
cgi and cgi-bin zippy Perl Misc 5 02-02-2005 01:46 AM
Python CGI - Accepting Input, Invoking Another Process, Ending CGI LarsenMTL Python 4 11-04-2004 05:59 PM
Calling cgi from cgi thru 'system' function. Different behaviour on browser v/s cmd line Shailan Perl 2 12-15-2003 04:26 PM
Re: CGI Perl "use CGI" statement fail Jürgen Exner Perl 0 07-31-2003 02:00 PM



Advertisments