T
tengounplanb
Hi,
I'm using a simple form to make possible the users of our site upload
files.
<html>
<head><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head>
<body>
<form method="post" enctype="multipart/form-data" action="/ws/
upload.py"/>
<input name="upfile" type="file" size="50"/><br>
<input type="submit" value="send"/>
</form>
</body>
</html>
The "upload.py" looks like this:
from mod_python import apache, util;
def index(req):
form = util.FieldStorage(req, keep_blank_values=1)
try:
# form is empty here
# return form --> I get "{}"
ufile = form.get('upfile', None)
if not form.has_key('upfile'):
return " No 'upfile' key"
# some checks. I never get beyond here
ufile = form['upfile']
if ufile.file:
return ufile.file.name
else:
return " It's not a file"
except Exception, e:
return 'Fail: ' + str(e)
I'm getting an empty 'form'. No 'upfile' key at all. I've tried to add
some other text fields but the result is the same: empty. If I use GET
method with text fields, it works properly.
Currently I'm using:
Apache 2.2.9 (initially I used Apache 2.2.3 too)
mod_python 3.3.1 (initially I used mod_python 3.2.10 too)
Python 2.5.2
Thanks
Best regards,
León
I'm using a simple form to make possible the users of our site upload
files.
<html>
<head><meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head>
<body>
<form method="post" enctype="multipart/form-data" action="/ws/
upload.py"/>
<input name="upfile" type="file" size="50"/><br>
<input type="submit" value="send"/>
</form>
</body>
</html>
The "upload.py" looks like this:
from mod_python import apache, util;
def index(req):
form = util.FieldStorage(req, keep_blank_values=1)
try:
# form is empty here
# return form --> I get "{}"
ufile = form.get('upfile', None)
if not form.has_key('upfile'):
return " No 'upfile' key"
# some checks. I never get beyond here
ufile = form['upfile']
if ufile.file:
return ufile.file.name
else:
return " It's not a file"
except Exception, e:
return 'Fail: ' + str(e)
I'm getting an empty 'form'. No 'upfile' key at all. I've tried to add
some other text fields but the result is the same: empty. If I use GET
method with text fields, it works properly.
Currently I'm using:
Apache 2.2.9 (initially I used Apache 2.2.3 too)
mod_python 3.3.1 (initially I used mod_python 3.2.10 too)
Python 2.5.2
Thanks
Best regards,
León