I have an uploaded file in uploads folder and i need to read the contents from it in the controller for processing it further. I have very basic knowledge of web2py and couldn't understand how to do it.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can do something like:
import os
filename = db.mytable(record_id).myfile
content = open(os.path.join(request.folder, 'uploads', filename), 'rb').read()
UPDATE: Here is a somewhat simpler approach.