Additionally, after looking at the source code I came up
with this
solution:
from cherrypy import _cpcgifs
class MyFieldStorage(_cpcgifs.FieldStorage):
def make_file(self, binary=None):
print "Making binary file"
filename = self.filename
length =
int(cherrypy.request.headerMap['Content-Length'])
print "file: %s length:%d" % (filename,
length)
dest_filename = "c:/tmp/uploads/" +
filename
return open(dest_filename, "w+b");
_cpcgifs.FieldStorage = MyFieldStorage
So, to implement an upload progress bar you can use the
above to create
the file and make a record somewhere (session or database)
of the
filename (dest_filename) and size.
On the client side, make a periodic asynchronous call to the
server
requesting the total uploaded so far. The server returns
the current
size of the uploading file (dest_filename). A dash of DHTML
to show
your progress bar should do nicely.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---
|