Progress bar in web-based ftp?

Larry Bates larry.bates at websafe.com
Tue May 9 15:36:16 EDT 2006


CatDude wrote:
> I've got an application that prompts the user to select a file from his
> local computer, checks the user's selection, then sends the file via 
> <form name="clients" method="POST" action="upload"
> enctype="multipart/form-data">
> 
> In the python code that receives the files I've got a section that does
> the following:
> 
>             if not os.path.isfile(filePath):
>                 file(filePath, 'wb').write(str(form[name].value))
>             else:
>                 print "File already exists - deleting"
>                 os.unlink(filePath)
>                 file(filePath, 'wb').write(str(form[name].value))
> 
> after error checking, etc.
> 
> My question is whether anyone has ideas as to how I could implement a
> progress bar. When I send a large file this way it can take a long time,
> and I'd like to be able to reassure the user that something really is
> happening.
> 
> 
Turns out that this is more difficult than you might think.  The problem
is you must have the client communicate with the server in some way and
have the server know what the progress is at any point.  HTML POST
action=upload doesn't give you anything to work with to provide such
information to the client's browser (if it does I'm not aware of it
anyway).  It also would take something like JavaScript and XMLRPC on
the client to make the round trip to get updated progress information.

-Larry Bates



More information about the Python-list mailing list