[mod_python] file uploads and StringField / Field instances

Volodya volodya at real.samuraj.org
Sat Mar 13 21:26:23 EST 2004


I'm experimenting with form-based file uploads (mod_python.publisher
handler). After reading mod_python-docs, i expect to get an instance of
Field class in one of req.form's items. But i always get StringField

My html-code:

<head><title>file upload</title></head>
<FORM NAME="upload" ACTION="save.py"
   ENCTYPE="multipart/form-data" METHOD="post">
   <INPUT TYPE="file" NAME="upload"/>
   <INPUT TYPE="submit" VALUE="Upload">

Handler's code: 

def index(req):
	return type(req.form['upload'])

And the output is always : <class 'mod_python.util.StringField'>

Env: win32 , apache 2.0.48 , mod_python 3.1.2b , Python 2.3.3
Browsers: IE 6.0 , Mozilla 1.3

Getting the file as a string is not a big problem with small files. But
when clients will upload huge files simultaneously it will be a problem.
What am i doing wrong ?

Here is the capture of http-request from IE (Mozilla's one looks similar):

POST /save.py HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: ru
Content-Type: multipart/form-data;
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Content-Length: 257
Connection: Keep-Alive
Cache-Control: no-cache

Content-Disposition: form-data; name="upload"; filename="C:\123.gif"
Content-Type: image/gif
[    binary data of 123.gif goes here    ]

More information about the Mod_python mailing list