[mod_python] upload file?

Volodya volodya at real.samuraj.org
Fri May 7 16:35:28 EST 2004

On Fri, May 07, 2004 at 08:14:02AM -0400, John Mudd wrote:
> I'm still trying to upload a file.
> I reduced my mod_python code to a small example and attached it.  It
> uses HTMLgen to generate the HTML.  I've listed the HTML and the trace
> output below.  The name of the file I'm trying to upload is
> 'zopeIntro.txt'.  I'm using Apache/2.0.49 (Unix) mod_python/3.1.3
> Python/2.3.
> I'm hoping this will make whatever mistake I'm making easier to see. 
> Any suggestions?

Here is simple example of working file uploads (using publisher

Tested on FreeBSD 4.9 (i've also tested similar code on win32 several weeks ago):
  Apache 2.0.48,
  mod_python 3.1.3 (+ mentioned patch by David Fraser),
  Python 2.3.3

= 8< ======== .htaccess =========================
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
= >8 ============================================

= 8< ======== index.py ==========================
html = """
<form action="upload" method="POST" enctype="multipart/form-data">
  <input type="file" name="fileupload"/>
  <input type="submit" value="Upload!">

def index(req):
    return html

def upload(req):
    fp = req.form['fileupload'].file
    return type(fp)
= >8 ============================================


<type 'file'>

Hope this help.

More information about the Mod_python mailing list