weblispcommon-lisphunchentoot

How to handle multiple file upload in hunchentoot?


I know how to handle a single file upload in hunchentoot using hunchentoot:post-parameter, but when I add a property multiple, i.e., <input name="file" type="file" multiple="multiple"/>. I got (hunchentoot:post-parameter "file") only for one of them. Is there (and what is ) the mechanism for receiving all files, chosen by user?


Solution

  • The Hunchentoot API does not directly give you access to multiple uploaded files, but you can use (hunchentoot:post-parameters *request*) to retrieve the list of all POST parameters (which includes the uploaded files). This will be an alist, and you can get a list of all uploaded files using standard alist techniques (e.g. (remove "file" (hunchentoot:post-parameters hunchentoot:*request*) :test (complement #'equal) :key #'car)).