|
From: Clark C . E. <cc...@cl...> - 2001-08-11 17:37:58
|
Hello. It seems that non-streaming "niave" upload of
files works well in WebKit using Win2K under Apache
and ActiveState Python. Following is source code
which may be interesting to include in the list
of examples... I have two questions:
1. Is there a way to short-circut this operation so
that any "file" parameter is saved to a temporary
file and that the variable is filled with the
fully qualified path of the temp file?
2. The code below doesn't seem to work with the
OneShot adapter and binary files. Text files
have no problem, but binary file upload causes
the OneShot adapter based WebKit to take a
lunch break.
Best,
Clark
#--------------------------------------------------------------
from ExamplePage import ExamplePage
htmlForm = """
<form enctype="multipart/form-data" method="post">
<input type="file" name="file" />
<input type="hidden" name="fname" value="boogy_test.doc" />
<input type="submit" name="_action_" value="Submit" />
"""
htmlWrote = """
<html><body>Wrote: %s</body></html>
"""
class File(ExamplePage):
def actions(self): return ["Submit"]
def writeContent(self):
self.writeln(htmlForm)
def Submit(self,trans):
output = open(self.request().field("fname"),"wb")
output.write(self.request().field("file"))
output.close()
self.writeln(htmlWrote % self.request().field("fname"))
|