[mod_python] upload file?

John Mudd johnmudd at mindspring.com
Fri May 7 10:09:15 EST 2004


Oh, thanks!  I see three areas I need to change.  The header, the action=function and adding the load function.  Cool!

John

-----Original Message-----
From: Volodya <volodya at real.samuraj.org>
Sent: May 7, 2004 9:35 AM
To: mpMailList <mod_python at modpython.org>
Subject: Re: [mod_python] upload file?

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
handler).

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 = """
<html><body>
<form action="upload" method="POST" enctype="multipart/form-data">
  <input type="file" name="fileupload"/>
  <input type="submit" value="Upload!">
</form>
</body></html>
"""

def index(req):
    return html

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


Output:

<type 'file'>

Hope this help.


_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list