Skip to content Skip to sidebar Skip to footer

How To Use Python/CGI For File Uploading

I'm trying to make a file uploader page that will prompt the user for a file and will upload while displaying progress. At the moment I've managed to make a simple HTML page that

Solution 1:

This is more complex than it seems, given how file uploading works in the HTTP protocol. Most web servers will give control to the CGI script only when the uploaded file has been completely transferred, so there's no way to give feedback in the meanwhile.

There are some Python libraries that attempt to tackle this issue, though. For example: gp.fileupload (works with WSGI, not CGI).

The trick is to provide a way to query the upload progress via AJAX while still transferring the uploaded file. This is of no use if the web server (for example, Apache or nginx) is not configured to support the upload progress feature because you will probably see a 0% to 100% jump in the progress bar.

I suggest you try Plupload, which works on the client-side and is much simpler.


Post a Comment for "How To Use Python/CGI For File Uploading"