Reading file content from uploaded text file

陌路散爱 提交于 2019-12-08 04:15:45

问题


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.



来源:https://stackoverflow.com/questions/26968216/reading-file-content-from-uploaded-text-file

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