我知道如何使用hunchentoot:post-paremter在hunchentoot中处理单个文件上传,但是当我添加一个属性multiple,即<input name="file" type="file" multiple="multiple"/>时,我只为其中一个添加了(hunchentoot:post-paraameter "file")。是否有(以及是什么)机制来接收用户选择的所有文件?
发布于 2013-03-07 05:48:40
Hunchentoot API不能直接访问多个上传的文件,但是您可以使用(hunchentoot:post-parameters *request*)来检索所有POST参数的列表(包括上传的文件)。这将是一个列表,您可以使用标准的列表技术(例如(remove "file" (hunchentoot:post-parameters hunchentoot:*request*) :test (complement #'equal) :key #'car))获取所有上传文件的列表。
发布于 2016-09-11 03:08:15
在hunchentoot中,这是一个相当简单的任务。假设您有一个带有name="files"和multi="true"的html元素,您可以访问与“<input>”输入关联的所有文件,如下所示:
(loop for post-parameter in (hunchentoot:post-parameters*)
if (equal (car post-parameter) "files")
collect post-parameter))这将为您提供一个列表,该列表的长度应与与名称" files“相关联的上传文件的数量相匹配。每个元素都是如下所示的列表:
("files" #P"/temporary/file1" "name of file" "file type")更多信息可以在文档非常完善的reference中找到。
https://stackoverflow.com/questions/15249921
复制相似问题