How to use Python/CGI for file uploading

穿精又带淫゛_ 提交于 2019-11-30 14:10:25

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!