获取文件上传的名称 - Google App Engine Python [英] Getting name of file upload - Google App Engine Python

查看:119
本文介绍了获取文件上传的名称 - Google App Engine Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的处理程序检查文件上传的扩展名,以确保用户不会上传恶意软件或不相关的文件。我似乎无法找到获取文件名服务器端的方法。 这个问题另一个说刚刚得到 self.request.get(file_input_name_attr).filename 但在最近的GAE版本中,文件对象是一个字符串,因此不能被要求 filename

I am trying to get my handler to check the extension of a file upload to ensure that the user isn't uploading malware or irrelevant files. I just can't seem to find a way to get the filename server-side. This question and another said to just get self.request.get("file_input_name_attr").filename but in the recent versions of GAE the file object is a string and therefore cannot be asked for filename.

以下是我的表单的相关部分:

Here's the relevant parts of my form:

<form action="/path" method="post" enctype="multipart/form-data">
    <input type="file" name="uploadFile" />
</form>

有些帖子(约2年前)说要做

Some posts (dating up to 2 years ago) say to do

self.request.POST["uploadFile"].filename

但对于我 self.request.POST [uploadFile] 返回一个空值

推荐答案

请参阅 Blobstore Python API概述,了解如何使用Appengine上传文件。

Please refer to the Blobstore Python API Overview, to see how files are uploaded with Appengine.

这篇关于获取文件上传的名称 - Google App Engine Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆