[mod_python] upload pop-up

python_it at hotmail.com python_it at hotmail.com
Mon Oct 17 06:51:00 EDT 2005


I’m trying to upload files with the following files/scripts:
When I’m testing my upload.htm in IE (windows) and click on my
Submit buttion a popup windows appears with the function to save or open
upload.py?

Ohter scripts works fine! No pop-up windows appears.

Help?

upload.htm
=======
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
  <form action="modules/upload.py" method="post" 
enctype="multipart/form-data" name="Uploadform" target="_self" 
id="Uploadform">
  <input type="file" name="file" />
  <input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>


upload.py
=======
from mod_python import psp,util

def index(req, file=None):
	req.content_type = 'multipart/form-data'
	tmpl = psp.PSP(req, filename='templates/upload.tmpl', vars={'req': req, 
'psp': psp, 'file': file})
	tmpl.run()


upload.tmpl
==========
<html>
%>
def getFile(file):
    if file is None:   # There was no file sent.
        return "Error! There was no file!"
    if type(file) is str:
	# File was sent as a regular field, which is bad.
        return "Error! File was a string!"
    fileData = file.read()    # Get the file data into a Python variable.
	req.write("DONE")
    return "Ok, file received."

getFile(file)
%>
</html>

_________________________________________________________________
Stuur een voiceclip met MSN Messenger 7.5 
http://www1.imagine-msn.com/Messenger/Video.aspx



More information about the Mod_python mailing list