I'll have to admit that... it was so easy to use $ _ file for file uploading in PHP.
Trying to switch to python from PhP (for varous reasons including shared Configuration between web and background processes, etc ). started looking at web. PY (with other alternatives as well) and, surprisingly, found that the webpy's document is nothing
More than... Nothing. Even the "receipts" in "cookbook" are for those who don't need them. So I'm lost totally just in handling uploaded file.
Task: to handle a file upload.
Solution:
Def post (Self): x = web. Input ('log', log = {})
Trick here is the log = {} Part. without it, X. log wocould be a string containing the whole content of the file. this is a completely uninitialized ented behavior. if you need something more familiar, specify the "log = {}" part, and you'll get X. log. filename
For remote filename and X. log. file for a file object to access it. I still haven'tfigured out how to directly operate on the uploaded file (or Python didn't do this part at all ?) But at least I got a file object to deal.
Related code:
Https://github.com/webpy/webpy/blob/master/web/utils.py#L160
If the key is not in the "defaults", or the specified defaults value isn't a dict, value is inflated before added to the storage object.