1
比方说,我有2个文件的格式如下:如何按正确的顺序处理上传的文件?
<!-- the field below contains actual upload file -->
<input type=hidden name="http://localhost:XXXX/some_unique_name_generated_by_Picasa_and_not_controlled_by_me">
<!-- the name of field below is equal to the uploaded above filename -->
<input type=hidden name="DSC04310.jpg" value="description of first file">
<input type=hidden name="http://localhost:XXXX/some_unique_name_generated_by_Picasa_and_not_controlled_by_me">
<input type=hidden name="DSC04306.jpg" value="description of second file">
不知怎的,他们上传的时候,我让他们在不同的顺序在服务器上 - DSC04306.jpg先DSC04310.jpg。我使用:
arguments = self.request.arguments()
files_arguments = []
for argument in arguments:
if 'localhost' in argument: # choose files only, not other fields
files_arguments.append(argument)
但我需要按照它们在窗体中的相同顺序来处理它们。 我想到了以下解决方案:
<input type=hidden name="http://localhost:XXXX/some_unique_name">
<input type=hidden name="DSC04310.jpg" value="description of first file">
<input type=hidden name="seq_DSC04310.jpg" value="1">
<input type=hidden name="http://localhost:XXXX/some_unique_name">
<input type=hidden name="DSC04306.jpg" value="description of second file">
<input type=hidden name="seq_DSC04306.jpg" value="2">
是不是好办法?如果是这样,那么如何根据seq_FILENAME
字段中的值对files_arguments
中的值进行排序?
感谢,赖斯,回答我的所有GAE相关的问题)。如果我使用'iteritems',我会以与上传相同的顺序得到它吗? –
这不是来自HTTP规范的东西,但实际上,是的。 – moraes
我不认为订单保证首先由浏览器保存,是吗?尽管如此,我很疑惑这些字段的处理顺序可能很重要。 –