|
From: Jay L. <js...@js...> - 2001-08-11 18:08:54
|
Clark-
What version of Webware are you using? The file upload code got a
rewrite in CVS HEAD. It now saves the file to a temp file and gives you
an open file handle, where that temp file will be deleted automatically.
If you want to hang on to the file, you need to pump it into your own file.
Jay
Clark C . Evans wrote:
>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"))
>
>
>
>_______________________________________________
>Webware-discuss mailing list
>Web...@li...
>http://lists.sourceforge.net/lists/listinfo/webware-discuss
>
|