获取名称和使用python扩展上传的文件(谷歌应用程序引擎) [英] Getting the name & extension of an uploaded file using python (google app engine)

查看:126
本文介绍了获取名称和使用python扩展上传的文件(谷歌应用程序引擎)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用表单将文件上传到Google应用引擎并将其存储在数据存储中。 l还希望存储原始文件名和扩展名以用于演示目的。

是否有从检索服务器端检索此数据的方法,或只能收集客户端并作为单独的字段发送(例如 http://www.tinyurl.com/5jybfq )?



非常感谢。

对于那些遵循以下答案的解决方案: >

  this_file = self.request.params [file_upload_form_field_name]。filename 

(this_file_name (this_file_extension)= os.path.splitext(this_file)

self.response.out.write(文件名:+ this_file_name +< br>)

self.response.out.write(File extension:+ this_file_extension +< br>)


解决方案

请阅读

  self.request.params [<包含文件的表单元素名称> ] .filename 


I am using a form to upload files to the google app engine and store them in the datastore. l would also like to store the original file name and extension for presentation purposes.

Is there a way of retrieving this data from the post sever side or can it only be gathered client side and sent as separate fields (e.g. http://www.tinyurl.com/5jybfq)?

Many thanks.

For those that follow the solution dased on the answer below:

this_file = self.request.params["file_upload_form_field_name"].filename 

(this_file_name, this_file_extension) = os.path.splitext(this_file) 

self.response.out.write("File name: " + this_file_name + "<br>") 

self.response.out.write("File extension: " + this_file_extension + "<br>") 

解决方案

Does the snippet from this email work?

 self.request.params[<form element name with file>].filename

这篇关于获取名称和使用python扩展上传的文件(谷歌应用程序引擎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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