【发布时间】:2013-04-24 08:00:51
【问题描述】:
我正在尝试使用以下方式上传文本文件:
<input type="file" name="file">
这个文件是通过以下方式检索的:
class UploadHandler(webapp2.RequestHandler):
def post(self):
file=self.request.POST['file']
self.response.headers['Content-Type'] = "text/plain"
self.response.write(file.value)
我的输出是:
Content-Type: text/plain MIME-Version: 1.0 Content-Length: 312 Content-MD5: MDIzYzM5YmNmOWRmMzY5Zjk2MTYzZTUzNjYwMTg5YjM= content-type: text/plain content-disposition: form-data; name="file"; filename="blah.txt" X-AppEngine-Upload-Creation: 2013-04-24 07:57:23.729774
有什么方法可以检索文件内容而不是上面的标题。 ??
【问题讨论】:
-
你确定 value 是类变量而不是类方法吗?
-
你的表单有 enctype="multipart/form-data" 属性吗?
标签: python google-app-engine text blobstore