[mod_python] file uploads and StringField / Field instances

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


Hello,

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
instance. 

My html-code:

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

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, */*
Referer: http://192.168.1.2/gal/manage/upload.html
Accept-Language: ru
Content-Type: multipart/form-data;
boundary=---------------------------7d412a1350100
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
Host: 127.0.0.1:8080
Content-Length: 257
Connection: Keep-Alive
Cache-Control: no-cache

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





More information about the Mod_python mailing list